RE: [Flashcoders] Question: Find out the "depth" of an xml file

2007-02-28 Thread Wenzler, Thomas
Thanks a lot Danny, i'll try and get my head around this. Much
appreciated!

 

Thomas

___
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


RE: [Flashcoders] Question: Find out the "depth" of an XML-File

2007-02-28 Thread Danny Kodicek
 
> 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; ihttp://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