# XML Parsers, Recursion problem

**URL:** <https://forum.kirupa.com/t/xml-parsers-recursion-problem/58442>\
**Category:** flash\
**Created:** [July 22, 2004, 2:54pm UTC](https://forum.kirupa.com/t/xml-parsers-recursion-problem/58442 "2004-07-22T14:54:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rschennink](https://avatars.discourse-cdn.com/v4/letter/r/dec6dc/32.png) [@rschennink](https://forum.kirupa.com/u/rschennink)\
**Post date:** [July 22, 2004, 2:54pm UTC](https://forum.kirupa.com/t/xml-parsers-recursion-problem/58442/1 "2004-07-22T14:54:31Z")

</div>

**FLASH MX 2004**

I am loading an xml and looping through it using a recursive function. The problem is that it only reads through the first tree and then quits…??

XML:

```php

<root id="0">
<dir id="1" name="Lounge,_Chillout">
<dir id="2" name="Opera_Chillout_2003">
<dir id="3" name="CD1">
	<pl>1e00ad1d-66ba-4496-8168-0d926422739c.xml</pl> 
	<tn>15</tn> 
</dir>
<dir id="4" name="CD2">
	<pl>47c5dc51-e0d6-4b5e-a837-76a18600fcd6.xml</pl> 
	<tn>14</tn> 
</dir>
</dir>
<dir id="5" name="Roger_Sanchez_-_First_Contact">
<pl>9c5eb7bf-9a0d-45e9-8e51-b2acccd66b17.xml</pl> 
<tn>9</tn> 
</dir>
<dir id="6" name="Royksopp_-_Melody_a.m">
<pl>7cbb66fd-2d33-427a-8627-cce502ee14b8.xml</pl> 
<tn>10</tn> 
</dir>
<dir id="7" name="Secret_Garden_-_Songs_from_a_Secret_Garden">
<pl>607bf25e-c1a1-4660-9b8b-0bf4731ae61a.xml</pl> 
<tn>12</tn> 
</dir>
</dir>
<dir id="8" name="Soundtracks">
<dir id="9" name="Army_Of_Darkness">
<pl>991a68ac-1be2-4201-b3ed-65d341e8134d.xml</pl> 
<tn>21</tn> 
</dir>
<dir id="10" name="Soundtrack_-_Reservoir_Dogs" /> 
</dir>
</root>

```

Actionscript:

```php
 
loadXml = function (filename) {
summaryXml = new XML();
summaryXml.ignoreWhite = true;
summaryXml.load("xmls/"+filename+".xml");
summaryXml.onLoad = function(success) {
if (success) {
getDirs(summaryXml,6);
}
};
 
getDirs = function(xml, id)
{
currentNodes = xml.childNodes;
for (var i=0; i< currentNodes.length; i++) {
 
if (currentNodes*.attributes.id == id) {
 
	trace("bingo @ " + currentNodes*.attributes.name);
 
	} else {
 
	if (currentNodes*.hasChildNodes()) {
 
	 trace("search goes on @ id: " + currentNodes*.attributes.name);
 
	 getDirs(currentNodes*, id)
	}
	else
	{
	 trace("no more childs");
	}
}
}
};

```

the result is:

> 

search goes on @ id: undefined  
search goes on @ id: Lounge,\_Chillout  
search goes on @ id: Opera\_Chillout\_2003  
search goes on @ id: CD1  
search goes on @ id: undefined  
no more childs

I found a similar problem in another thread. i tried the solution from that thread but it didn’t solve my problem…

Does anyone have an idea?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 24, 2004, 2:16pm UTC](https://forum.kirupa.com/t/xml-parsers-recursion-problem/58442/2 "2004-07-24T14:16:57Z")

</div>

Anyone?? i’m going :krazy: :krazy: :krazy:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 24, 2004, 3:11pm UTC](https://forum.kirupa.com/t/xml-parsers-recursion-problem/58442/3 "2004-07-24T15:11:12Z")

</div>

your AS is giving errors…i’m trying to test it all. upload a zip with the .xml and .fla

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 24, 2004, 6:32pm UTC](https://forum.kirupa.com/t/xml-parsers-recursion-problem/58442/4 "2004-07-24T18:32:53Z")

</div>

i don’t have time to zip it all… there are some classes and an xml and a .fla file… the problem is located in the function i posted.
