# Building this object array

**URL:** <https://forum.kirupa.com/t/building-this-object-array/256343>\
**Category:** Uncategorized\
**Created:** [April 2, 2008, 6:35am UTC](https://forum.kirupa.com/t/building-this-object-array/256343 "2008-04-02T06:35:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)\
**Post date:** [April 2, 2008, 6:35am UTC](https://forum.kirupa.com/t/building-this-object-array/256343/1 "2008-04-02T06:35:05Z")

</div>

I was wondering how I could build an array like this:

```auto

var songs:Array = new Array(
[playList: listName[song: songName, src: songSrc],[song: songName, src: songSrc],[song: songName, src: songSrc]],
[playList: listName[song: songName, src: songSrc],[song: songName, src: songSrc],[song: songName, src: songSrc]],
[playList: listName[song: songName, src: songSrc],[song: songName, src: songSrc],[song: songName, src: songSrc]]
);

```

I have xml that looks like:

```auto

<music>
    <playlist title="Joey's Jams">
        <song title="Chico Man - Say What" src="music/pl1/song1.mp3" />
        <song title="Amy Winehouse - Valerie" src="music/pl1/song2.mp3" />
        <song title="The Flaming Lips - The W.A.N.D" src="music/pl1/song3.mp3" />
    </playlist>
    <playlist title="Jon's P-List">
        <song title="Nas - Ether" src="music/pl2/song1.mp3" />
        <song title="Tupac - Hail Mary" src="music/pl2/song2.mp3" />
        <song title="Tupac - Changes" src="music/pl2/song3.mp3" />
    </playlist>
    <playlist title="Marvin's Mix">
        <song title="Beck - Girl" src="music/pl3/song1.mp3" />
        <song title="Bruce Springsteen - Spirit In the Night" src="music/pl3/song2.mp3" />
        <song title="Sugar Ray - Fly" src="music/pl3/song3.mp3" />
    </playlist>
</music>

```

I have it all looping with this right now:

```auto

songxml.onLoad = function() {
    var listLength = songxml.firstChild.childNodes.length;
    for (var i = 0; i < listLength; i++) {
        var listTitle = songxml.firstChild.childNodes*.attributes.title;
        var songLength = songxml.firstChild.childNodes*.childNodes.length;
        playlist.push(listTitle);
        for (var k = 0; k < songLength; k++) {
            var songTitle = songxml.firstChild.childNodes*.childNodes[k].attributes.title;
            var songSrc = songxml.firstChild.childNodes*.childNodes[k].attributes.src;
            songs.push({songTitle:songTitle, songSrc:songSrc});
        }
    }
    init();
};
songxml.load("songlist.xml");

```

its just right now i have two arrays but the songs array isnt separated by anything…any ideas??
