# XML confusion: cycling through children

**URL:** <https://forum.kirupa.com/t/xml-confusion-cycling-through-children/204283>\
**Category:** flash\
**Created:** [October 18, 2006, 3:33pm UTC](https://forum.kirupa.com/t/xml-confusion-cycling-through-children/204283 "2006-10-18T15:33:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tedc](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@tedc](https://forum.kirupa.com/u/tedc)\
**Post date:** [October 18, 2006, 3:33pm UTC](https://forum.kirupa.com/t/xml-confusion-cycling-through-children/204283/1 "2006-10-18T15:33:45Z")

</div>

Hi, I am rather new to Flash and XML…

I have an XML file that looks something like this:

```auto

<?xml version="1.0" encoding="iso-8859-1"?>
<calc-growth>

<state name="california">
	<location city="san_francisco">
		<telephone>(555) 123-4567</telephone>
		<telephone2>(555) 123-456203456</telephone2>
		<fax>(555) 123-4569</fax>
		<address1>1 Main St.</address1>
		<address2>nothing</address2>
		<email>cali email</email>
	</location>
</state>

<state name="colorado">
	<location city="fort_collins">
		<telephone>(555) 123-4567</telephone>
		<telephone2>(555) 123-4568</telephone2>
		<fax>(555) 123-4569</fax>
		<address1>1 Main St.</address1>
		<address2></address2>
		<email></email>
	</location>
	
	<location city="boulder">
		<telephone>(555) 123-4567</telephone>
		<telephone2>(555) 123-4568</telephone2>
		<fax>(555) 123-4569</fax>
		<address1>1 Main St.</address1>
		<address2></address2>
		<email></email>
	</location>
	
	<location city="denver">
		<telephone>(555) 123-4567</telephone>
		<telephone2>(555) 123-4569</telephone2>
		<fax>(555) 123-4569</fax>
		<address1>1 Main St.</address1>
		<address2></address2>
		<email></email>
	</location>
</state>

<state name="connecticut">
	<location city="hartford">
		<telephone>(555) 123-4567</telephone>
		<telephone2>(555) 123-4568</telephone2>
		<fax>(555) 123-4569</fax>
		<address1>1 Main St.</address1>
		<address2></address2>
		<email></email>
	</location>
</state>

```

I have already been able to make an array based off of the names of the states:

```auto

xml.onLoad = function(ok) {
	avAll = this.firstChild.childNodes;
	avStates = new Array();
	for (var i = 0; i<avAll.length; i++) {
		avStates.push(avAll*.attributes.name);
	}
}

```

BUT, what I would like to do is create a multi-dimensional array with the state name and it’s cities.

So the array should be formatted like this:

```auto

trace(avStates[0][0]); //returns san_francisco
trace(avStates[1][0]); //returns fort_collins
trace(avStates[1][0]); //returns boulder
trace(avStates[1].length); //returns 3

```

Im sure its possible but Ive been trying and trying for hours to no avail. Ⓜ I dont know if I maybe formatted the XML file wrong for this type of thing?

HELP PLEASE!! 🙂
