# XML:Array within an array

**URL:** <https://forum.kirupa.com/t/xml-array-within-an-array/239838>\
**Category:** flash\
**Created:** [September 26, 2007, 1:58pm UTC](https://forum.kirupa.com/t/xml-array-within-an-array/239838 "2007-09-26T13:58:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JTrest](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@JTrest](https://forum.kirupa.com/u/JTrest)\
**Post date:** [September 26, 2007, 1:58pm UTC](https://forum.kirupa.com/t/xml-array-within-an-array/239838/1 "2007-09-26T13:58:17Z")

</div>

**Hello.**  
**I have the following Actionscript:**

var controlArray:Array;  
var variable:Array;  
var controlsXML:XML = new XML();  
controlsXML.ignoreWhite = true;  
controlsXML.onLoad = function(success:Boolean){  
if (success){  
var mainnode:XMLNode = controlsXML.firstChild;  
var controlNodes:Array = controlsXML.firstChild.childNodes;

//trace (controlNodes);  
for (var i:Number = 0; i \< controlNodes.length; i++) {  
var personnode:XMLNode = controlNodes\*.attributes.id;  
trace(personnode);  
var specificNode:Array = controlNodes\*.firstChild.childNodes;  
for (var j:Number = 0; j \< specificNode.length; j++){  
var itemnode:Array = specificNode[j].nodeValue;  
trace(specificNode[j]);  
//trace(itemnode);  
}  
}

} else {  
trace(‘error reading XML’);  
}  
};  
controlsXML.load (“new.xml”);

**And the following XML(new.xml):**

\<?xml version=“1.0” encoding=“UTF-8”?\>  
\<phoneBook\>  
\<contact id=“1”\>  
\<name\>Sas Jacobs\</name\>  
\<address\>123 Some Street, Some City, Some Country\</address\>  
\<phone\>123 456\</phone\>  
\</contact\>  
\<contact id=“2”\>  
\<name\>John Smith\</name\>  
\<address\>4 Another Street, Another City, Another Country\</address\>  
\<phone\>456 789\</phone\>  
\</contact\>  
\<contact id=“3”\>  
\<name\>Jo Bloggs\</name\>  
\<address\>7 Different Street, Different City, UK\</address\>  
\<phone\>789 123\</phone\>  
\</contact\>  
\</phoneBook\>

**When I run the traces I get:**

1  
Sas Jacobs  
2  
John Smith  
3  
Jo Bloggs

**What I want is:**

1  
Sas Jacobs  
123 Some Street, Some City, Some Country  
123 456  
2  
John Smith  
4 Another Street, Another City, Another Country  
456 789  
3  
Jo Bloggs  
7 Different Street, Different City, UK  
789 123

**What am I doing wrong? Thx!**
