0

I need to use a string to access nodes and attributes in XML using E4X. It would be ideal to have this scenario (with XML already loaded):

var myXML:XML = e.target.data;

var myStr:String = "appContent.bodyText.(@name == 'My Text')";

myXML.myStr = "New Value for bodyText node where attribute('name') is equal to 'My Text'";

I ultimately need to set new values to an XML document using strings as E4X expressions.

4

1 回答 1

0

如上所述:

我想出了一个解决方法

  • 取你要定位的 E4X 路径的字符串

  • 拉出 E4X 路径并将其与目标路径进行比较

  • 如果两者相等,请使用该节点/属性执行您的操作

这是一个黑客,但它的工作原理。您甚至可以解析 XML 并使用目标字符串和目标节点填充数组,然后您可以通过数组中的项目访问它。这可以通过多种方式进行扩展。只要一切都设置为正确的垃圾收集,你会没事的。

于 2014-10-31T21:21:48.970 回答