How to get the xml tag name when iterating through a XMLList in ActionScript?
What I want to do is loop through an xml file, and assign the contents of each node to a static variable with the same name.
So for instance for
<it开发者_如何学编程em1>blah<item1>
<item2>tasdsddssda</item2>
<item3>asdasdasd</item3>
var xmlNodes:XMLList = xml.children();
for (var i = 0; i < xmlNodes.length(); i++) {
ClassName[tagName] = xmlNodes[i];
}
How do I get the tagName for the tag?
Have been looking through the documentation for XML
and XMLList
but couldn't spot how to do it unless I'm having one of my blind moments. I tried .name but that didn't work. I spotted that I could do it with toXMLString()
but thought there must be a nicer way?
var xmlNodes:XMLList = xml.children();
for each (var item:XML in xmlNodes) {
ClassName[item.name()] = item;
}
See the livedocs.
精彩评论