views:

41

answers:

1

var node:XML;

In flex/actionscript 3, I can call node.attribute("somename") and get the value of the "somename" atribute of the node. I can also call node.attributes() and get the VALUES of ALL the attributes. But how the heck do I know what attributes to look for?! The application I am creating does not know the format of the XML file in advance. I need a way to know the NAMES of the attributes of the nodes, before I can access them by name!

Help!

+6  A: 

Taken from AS3 Docs:

XMLList attribs = node.@*;
for (var i:int = 0; i < attribs.length(); i++)
{ 
   trace(attribs[i].name());     // attribute name
} 

Check the docs for more, you can do some pretty slick stuff with XML using AS3.

iandisme
agreed. I prefer using XML variables, very easy to get at your any part of your var and very easily traced out to get a visual representation of your data. I found this to be a vital read when dealing with XML: http://livedocs.adobe.com/flex/3/html/help.html?content=13_Working_with_XML_08.html
invertedSpear