XML Objects in Flash Player 8 have an additional property called idMap. This property is an object that contains a reference to each and every xml node in the xml document that has an id attribute defined. The name of each property in the XML.idMap object is the value of the id attribute. So for example if i had an xml node that had an id attribute of 0001:
-
<contact id='0001'>
-
<name>Guy Watson</name>
-
<telephone>00447837924006</telephone>
-
</contact>
There would be a property defined in the XML.idMap object called "0001" and its value would be a reference to that particular xml node instance:
-
xmlStr='<contact id='0001'><name>Guy Watson</name>'
-
xmlStr+='<telephone>00447837924006</telephone>'
-
xmlStr+='</contact>'
-
myXML=new XML(xmlStr)
-
myXML.ignoreWhite=true
-
trace(myXML.idMap['0001'])
You can use this object to quickly locate particular nodes of interest, by simply assigning them a unique id in the xml file.
[update] Turns out it was actually easier to do with actionscript in previous versions of the Flash Player using myXml['0001'] for example. However if you publish your Flash Movie for Flash Player 8, the old way doesnt work anymore, so this is the way to do it instead. [/update]