Detecting the NAMES (not values!) of the attributes of an XML node in flex/as3
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.开发者_如何学JAVA 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!
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.
精彩评论