# XML Nested Loops

**URL:** https://forum.kirupa.com/t/xml-nested-loops/209824
**Category:** flash
**Created:** [December 12, 2006, 6:34pm UTC](https://forum.kirupa.com/t/xml-nested-loops/209824 "2006-12-12T18:34:49Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![bigbstanley](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@bigbstanley](https://forum.kirupa.com/u/bigbstanley)
#### Post date: [December 12, 2006, 6:34pm UTC](https://forum.kirupa.com/t/xml-nested-loops/209824/1 "2006-12-12T18:34:49Z")

</div>

I’ve followed along with image gallery/slideshow tutorial and it works great. However, I’m trying to make it a bit more complex in which I need to access nested loops. I’ve tried a few things, but nothing seems to work. Any help would be greatly appreciated.

Here is my XML:

```auto

<resorts looptime="2">
    <location>
        <image>images/pic01.jpg</image>
        <island>Island 1</island>
        <link>http://www.google.com</link>
        <bullets>
            <item>Item 1</item>
            <item>Item 2</item>
            <item>Item 3</item>
            <item>Item 4</item>
        </bullets>            
    </location>
    
    <location>
        <image>images/pic02.jpg</image>
        <island>Island 2</island>
        <link>http://www.google.com</link>
        <bullets>
            <item>Item 1</item>
            <item>Item 2</item>
            <item>Item 3</item>
            <item>Item 4</item>
        </bullets>            
    </location>
    
    <location>
        <image>images/pic03.jpg</image>
        <island>Island 3</island>
        <link>http://www.google.com</link>
        <bullets>
            <item>Item 1</item>
            <item>Item 2</item>
            <item>Item 3</item>
            <item>Item 4</item>
        </bullets>            
    </location>

```

The nested loop is bullets. This is where I’m having my problem.

Here is my AS:

```auto

function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        image = [];
        island = [];
        link = [];
        bullets = [];
        
        
        total = xmlNode.childNodes.length;        
        
        delay = (this.firstChild.attributes.looptime)*1000;
        
        for (i=0; i<total; i++) {
            
            image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
            island* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
            link* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
            bullets* = xmlNode.childNodes*.childNodes[3].firstChild;
        }
        
        
        // my effort a nested loop
        for (b=0; b<bullets*.length; b++){
            item = bullets*.firstChild.nodeValue;
            trace(item);
        }
        
        firstImage();
        
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("info.xml");

```

I’ve tried doing a simple loop but for the life of me, I can’t seem to get it to work. Thanx in advance!
