# Looping through childNodes - Please help?

**URL:** <https://forum.kirupa.com/t/looping-through-childnodes-please-help/81238>\
**Category:** flash\
**Created:** [March 1, 2005, 2:20am UTC](https://forum.kirupa.com/t/looping-through-childnodes-please-help/81238 "2005-03-01T02:20:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![whtwoof](https://avatars.discourse-cdn.com/v4/letter/w/2bfe46/32.png) [@whtwoof](https://forum.kirupa.com/u/whtwoof)\
**Post date:** [March 1, 2005, 2:20am UTC](https://forum.kirupa.com/t/looping-through-childnodes-please-help/81238/1 "2005-03-01T02:20:51Z")

</div>

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:

```auto

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 :

```auto

<?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>

```
