# Help loading xml attributes into an array

**URL:** <https://forum.kirupa.com/t/help-loading-xml-attributes-into-an-array/225015>\
**Category:** flash\
**Created:** [May 8, 2007, 4:26am UTC](https://forum.kirupa.com/t/help-loading-xml-attributes-into-an-array/225015 "2007-05-08T04:26:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptrok](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@ptrok](https://forum.kirupa.com/u/ptrok)\
**Post date:** [May 8, 2007, 4:26am UTC](https://forum.kirupa.com/t/help-loading-xml-attributes-into-an-array/225015/1 "2007-05-08T04:26:38Z")

</div>

I have an old gallery that loaded a set of pictures and swf’s from a folder using an array  
arMedia = [“clip2.swf”, “image01.jpg”, “clip2.swf” … etc …];  
I wanted to update this by using xml to generate that array and came up script below.

```auto
 
//load media paths from xml into an array for gallery or pictuers and swf files
var galleryXML:XML = new XML(); 
galleryXML.ignoreWhite = true; 
 
galleryXML.onLoad = function(loaded:Boolean) {if (loaded) { 
    arMedia = new Array;
    arMedia = XML2Array(this);
    trace(arMedia);
 } else { 
    trace("XML could not load"); 
    } 
}; 
 
galleryXML.load("gallerypaths.xml"); 
function XML2Array(myXML:XML) { 
    arXML = new Array(); 
    var nodes:Number = myXML.firstChild.childNodes.length;
    for (i = 0; i < nodes; i++) { 
         arXML* = myXML.firstChild.childNodes*.attributes.media; 
    } 
    return(arXML);
}

```

XML seems to load and when I trace ‘arMedia’ it appears the same as if I traced the orginal array. However my gallery code does not appear to be reading the array??

I am failry new to XML - is there a difference in the way

```auto
 arXML* = myXML.firstChild.childNodes*.attributes.media; 

```

generates an element as compared with a normal array??  
I’ve hunted through this forum … but I am still stumped.  
Appreciate any help or suggestions

xml is very simple of the form:

```auto

<?xml version="1.0" encoding="iso-8859-1"?>
<GALLERY> 
<ITEM media="clip1.swf" /> 
<ITEM media="image01.jpg" /> 
<ITEM media="clip2.swf" /> 
<ITEM media="image02.jpg" /> 
 
etc....
</GALLERY>

```
