Reputation:
I have 2 xml files and one function to parse them. The function has to know how to parse them according to the xml document root node name.
How can I get the root name?
Upvotes: 3
Views: 2767
Reputation: 48127
Assuming you have this XML:
var xml:XML = <TheRootNode><someData /></TheRootNode>;
Then to get the root node, you just call name()
:
Alert.show(xml.name()); // Displays "TheRootNode"
Cheers!
Upvotes: 3
Reputation: 51837
You can try the name() or localName() methods:
var xml:XML = <root><child /></root>
trace(xml.name());
trace(xml.localName());
Upvotes: 5