From some xml I want to find items that have a specific attribute and value.
Here is example xml:
<node>
<node>
<node>
<special NAME="thisone"></special>
</node>
<node>
<special>dont want this one</special>
</node>
</node>
</node>
(nodes can contain nodes…)
I need to find the first based on it has an attribute named “NAME” and value of “thisone”.
then I need its parent (node).
I tried this:
specialItems = tempXML.*.(hasOwnProperty(“NAME”));
but didnt seem to do anything.
??
Thanks!
In ActionScript you’ll use E4X rather than XPath, generally. What you want can be achieved like this:
If you know the node you want is a
special, then you can use:instead. Here’s a nice E4X tutorial.
If you use the
@NAME == "thisone"syntax, then you do need the NAME attribute on all of your XML nodes, but not if you use theattribute()operator syntax instead.I added the
parent()call above; you could get the parent directly by using the child only in the conditional: