This is making me feel stupid :-). Say I start at a leaf node, and I traverse up the tree by using .parent(). I need an exit condition once it hits root. At the moment, I'm using parent.@name != "root", where name is just an attribute, but shouldn't I be able to check the type of element as well? How? Also, is there another way to end the traversal in as3?
+3
A:
Assuming you are using the XMLNode object:
if (currentNode.parentNode == null)
// Root
And if you are using the XML object:
if (!xmlNode.parent())
// Root
clownbaby
2010-08-11 21:11:45
Thanks! also, how do you check what the type of an xml element is?
Gary
2010-08-12 15:00:54
If you are asking how to check if you are using XMLNode VS XML... then the answer is: you should already know because you are writing the code.If you are asking if the XMLNode you are working on is text or an element, look at XMLNode.nodeType.Hope this helps.
clownbaby
2010-08-12 15:45:30