You are here: Home > Programming > Flash programming > XML > The secret id tag

The secret id tag

Print versionEdit this page
An XML object can be traversed by giving each node an 'id' attribute, for example <menuitem id="about"></menuitem>.

Undocumented, but it works. See attached examples below.

Trace output:

this.items = <items id="items"><item id="ABC"><img url="imageA.jpg" /><img url="imageB.jpg" /><img url="imageC.jpg" /></item><item id="DEF"><img url="imageD.jpg" /><img url="imageE.jpg" /><img url="imageF.jpg" /></item><item id="GHI" /><item id="JKL" /></items>
ABC = <item id="ABC"><img url="imageA.jpg" /><img url="imageB.jpg" /><img url="imageC.jpg" /></item>
ABC children = <img url="imageA.jpg" />,<img url="imageB.jpg" />,<img url="imageC.jpg" />
ABC first image = <img url="imageA.jpg" />

Problems

ids cannot be numbers.
This also works in AS2, however since "eval" is no longer available, I don't know of a way to iterate through a series of items. So this seems mainly handy when the ids are known in advance.


Topic contributors:
-- ArthurClemens - 15 Jan 2004
-- StephanBezoen - 15 Jan 2004

Attachment: sort Action: Size: Date: Who: Comment:
XML_id_test.fla action 14848 15 Jan 2004 - 13:12 ArthurClemens  
XML_id_test.swf action 331 15 Jan 2004 - 13:13 ArthurClemens  
items.xml action 368 15 Jan 2004 - 13:13 ArthurClemens  
main.as action 570 15 Jan 2004 - 13:13 ArthurClemens