this is my first question to the list... I need to find out
the depth of a given xml file to afterwards find one specific
node in the whole document.
Right now I stacked some loops into each other but that is
bad practice since I never can be sure if I reach the deepest
child in my search and on the other hand have those loops
running no matter if it's worth while.
So what I need is a completely different approach to my problem...
I hope I could make myself understood here and thanks in
advance for your help,
Recursion is your friend:
function getDepth(tXML:XMLNode):Number {
if (tXML.nodeType == 3) {
return 0
} else {
var tRet:Number = 0
for (var i = 0; itXML.childNodes.length; i++) {
tRet = Math.max(getDepth(tXML.childNodes[i]), tRet)
}
return tRet
}
}
Danny
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com