Searching XML, to arrays

Hi all,

I’m trying to search through xml data and then load the inforamtion into seperate arrays. Below is the xml I’m searching and I want to collect it in red_arr, blue_arr and green_arr

Code:
portfolio>
<red>
<image>red1</image>
<image>red2</image>
<image>red3</image>
<image>red4</image>
<image>red5</image>
</red>
<blue>
<image>blue1</image>
<image>blue2</image>
<image>blue3</image>
</blue>
<green>
<image>green1</image>
<image>green2</image>
<image>green3</image>
</green>
</portfolio>

Here is my Actionscript

ActionScript:
my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success) {
if (success) {
searchXML();
} else {
trace(“xml not loaded”);
}
};
blue_arr = new Array();
red_arr = new Array();
green_arr = new Array();
my_xml.load(“colors.xml”);
function searchXML() {
var start = my_xml.firstChild.childNodes;
for (var i = 0; i<start.length; i++) {
var allxml = start*;
if (allxml.nodeName == “blue”) {
blue = allxml.childNodes;
for (var n = 0; n<blue.length; n++) {
blue_arr.push(blue[n].childNodes);
trace(blue_arr);
//trace(blueValue);
}
}
if (allxml.nodeName == “red”) {
red = allxml.childNodes;
for (var j = 0; j<red.length; j++) {
red_arr.push(red[j].childNodes);
trace(red_arr);
//trace(redValue);
}
}
if (allxml.nodeName == “green”) {
green = allxml.childNodes;
for (var k = 0; k<green.length; k++) {
green_arr.push(green[k].childNodes);
trace(green_arr);
//trace(greenValue);
}
}
}
}

This works fine up to now, but the arrays are

Code:
red1
red1,red2
red1,red2,red3
red1,red2,red3,red4
red1,red2,red3,red4,red5

and I just need

Code:
red1,red2,red3,red4,red5

Also can anyone see a better way to do the actionscript, I dont know if its to repetitive, could I do this with two loops.