# Random XML Photo Galley

**URL:** https://forum.kirupa.com/t/random-xml-photo-galley/234827
**Category:** flash
**Created:** [August 6, 2007, 3:06pm UTC](https://forum.kirupa.com/t/random-xml-photo-galley/234827 "2007-08-06T15:06:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![bethanol](https://avatars.discourse-cdn.com/v4/letter/b/e480ec/32.png) [@bethanol](https://forum.kirupa.com/u/bethanol)
#### Post date: [August 6, 2007, 3:06pm UTC](https://forum.kirupa.com/t/random-xml-photo-galley/234827/1 "2007-08-06T15:06:50Z")

</div>

I am trying to create a photo gallery using xml that is random. I can’t seem to get it to work. Here is the code I am using:

```auto
function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        image = [];
        total = xmlNode.childNodes.length;
        i=Math.ceil(Math.random()*total);
        while (i<total) {
            image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
            caption* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
            photo_name* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
            i++;
            }        
        firstImage();
    } else {
        content = "file not loaded!";
    }
}

```

It is based of the code in this tutorial: [http://www.kirupa.com/developer/mx2004/xml\_flash\_photogallery.htm](http://www.kirupa.com/developer/mx2004/xml_flash_photogallery.htm)

Any help would be appreciated. Thanks.
