Can anyone help me figure out how to loop through the childNodes from my XML file? I even tried trace statements and they come back right but my code is only grabbing the very first “link”.
I have created the following AS:
if (ok) {
allData = this.firstChild.childNodes;
for (i=0; i<allData.length; i++) {
nodeID = Number(allData*.attributes.ID);
_level0.dataArray[nodeID] = new Object();
var thisNodeObj = _level0.dataArray[nodeID];
thisNodeObj.text = allData*.attributes.text;
trace (allData*.attributes.text);
thisNodeObj.prnt = Number(allData*.firstChild.attributes.to);
trace (allData*.firstChild.attributes.to);
And uses the following XML :
<?xml version="1.0" encoding="iso-8859-1"?>
<nodes>
<but text="Node 1" ID="1">
<link to="2"></link>
<link to="3"></link>
<link to="4"></link>
<link to="5"></link>
</but>
<but text="Node 2" ID="2">
<link to="3"></link>
<link to="4"></link>
<link to="5"></link>
</but>
<but text="Node 3" ID="3">
<link to="4"></link>
<link to="5"></link>
</but>
<but text="Node 4" ID="4">
<link to="5"></link>
</but>
<but text="Node 5" ID="5">
</but>
</nodes>