Groups | Blog | Home
all groups > flash actionscript > january 2005 >

flash actionscript : XML - Code for Traversing the Tree


BillG-Chicago
1/19/2005 11:29:18 PM
Does anyone have Flash 7 Actionscript 2.0 code for traversing an XML document
(and, for example, tracing the contents to the output window) without the use
of the XML Component? Any help would be extremely appreciated...Thanks!

Bill
abeall
1/19/2005 11:43:31 PM
Well, I am not a programmer by trade, but I can tell you that this will recurse
through the entire tree, tracing the node values: traverseNodes(myXML);//init
tagging of children function traverseNodes(node){ for(var i=0 ;
i<node.childNodes.length ; i++){ trace(node.childNodes[ i ].nodeValue);
if(node.childNodes[ i ].hasChildNodes){ traverseNodes(node.childNodes[ i
]) } } } (see attached Code also)

traverseNodes(myXML);//init tagging of children
function traverseNodes(node){
for(var i=0 ; i<node.childNodes.length ; i++){
trace(node.childNodes[i].nodeValue);

if(node.childNodes[i].hasChildNodes){
traverseNodes(node.childNodes[i])
}
}
}
AddThis Social Bookmark Button