Given this document:
<doc>
<element>
<list>
<key attr='val'/>
</list>
</element>
<element>
<list>
<key attr='other'/>
</list>
</element>
<element>
<list/>
</element>
开发者_开发百科</doc>
I want an e4x equivalent of the xpath //element[list/key/@attr="val"]
. Is it possible to do that?
..element.(list.key.@attr == "val")
xmlVarName.element.list.key.(@attr=="val");
alternative
xmlVarName..key.(@attr=="val");
It is important to note that
..element.(list.key.@attr == "val")
Can fail if the key nodes don't all have @attr.
The safest (although in my experience, not 100% successful) method to extract your node list would be.
..element.(list.key.attribute("attr") == "val")
However, I have had problems with e4x and conditional expressions, (AS3 implementation, Mozilla seems better.) but it seems to be down to the xml source.
精彩评论