Old Articles - 3 years, 3 months ago - 0 Comments

XML.idMap - Node Lookup Table

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:

XML:
  1. <contact id='0001'>
  2.     <name>Guy Watson</name>
  3.     <telephone>00447837924006</telephone>
  4. </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:

Actionscript:
  1. xmlStr='<contact id='0001'><name>Guy Watson</name>'
  2. xmlStr+='<telephone>00447837924006</telephone>'
  3. xmlStr+='</contact>'
  4. myXML=new XML(xmlStr)
  5. myXML.ignoreWhite=true
  6. 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]



Note: This is an old article!

Please be aware that the content of this article may no longer be accurate and the links contained within could be broken.

Update Notifications

You can add our RSS feed to your favorite feed reader or recieve an email when a new article is posted by entering your email address below.

    Shu Player allows you to distribute your AIR Applications to users that dont have the AIR Runtime by converting them to standalone applications. Shu Player also adds more commands to do things like open external applications etc...


    If you hate the Adobe Updater like most of us, then just get rid of it.


    Want to quickly find out what version of the Flash Player a client has installed? Send them to www.playerversion.com


    Yet more pv3d goodness. Im loving this funky 3D Flash Lab, the work of Mathieu Badimon. [Update: Apparently this uses Five3D not PaperVision]


    There is an old interview with me on The FWA, its fairly long at 8 pages.


    If you do alot of travelling then it makes sense to get yourself a Priority Pass, which will get you access to over 500 airport lounges worldwide, regardless of whether your flying enconomy, business or first.


    Freelance Switch is a freelancer community with forums, jobs, daily tips and a complete 212 page e-book titled "How to be a rockstar freelancer" for sale.


    Lots of new media jobs at Creative Pool.


    BBC IPlayer is awesome, but its ashame that BBC News is still using Windows Media Player and Real video. Real player is officially badware.


More In Actionscript


More In Adobe Flash


More In Freelancing