From some xml I want to find items that have a specific attribute and value.
Here is example xml:
nodes can contain nodes...
I need to find the special item because 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.
First you should load you xml string into
an xml object:
var myXml:XML = new XML("<xmlDataHere />");
Then you can get an XMLList of all the items you need by doing something like:
var myFoundItems:XMLList = myXml.descendants().attribute("NAME");
var myFoundItems:XMLList = myXml..(@NAME == "this one");
The first one would return a list of all descendants that have the attribute NAME. The second would get all descendants that have the attribute NAME that's value is "this one".
Here's the documentation pages for XML and XMLList:
Check out the examples sections.