var myXML:XML = <root>
<first>
<a title = "First Letter">
01234
</a>
<b title = "Second Letter">
56789
</b>
</first>
</root>
i would like to traverse the above XML searching only for an attribute. i don’t know about <first> or its children (<a> and <b>), or even which level the element containing the attribute (the XML can be much deeper than my example).
it seems that the descendent accessor does not work with finding elements based on their attribute. for example, i want to traverse the XML and find the element with the attribute “Second Letter”.
trace(myXML..(@title == "Second Letter"));
is it not possible to traverse an XML from the root and locate an element by an attribute?
Search for any node that have an attribute
title, here you can’t use e4x @title notation because not all node have an attribute title so you will get a compile time error :