# Code for XML file is tracing 'undefined'...why?

**URL:** https://forum.kirupa.com/t/code-for-xml-file-is-tracing-undefined-why/218568
**Category:** flash
**Created:** [March 8, 2007, 9:50pm UTC](https://forum.kirupa.com/t/code-for-xml-file-is-tracing-undefined-why/218568 "2007-03-08T21:50:20Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lariat1997](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@lariat1997](https://forum.kirupa.com/u/lariat1997)
#### Post date: [March 8, 2007, 9:50pm UTC](https://forum.kirupa.com/t/code-for-xml-file-is-tracing-undefined-why/218568/1 "2007-03-08T21:50:20Z")

</div>

Hey all,

I want to create variables using the length of an XML childnode as the iterator. I would like to create vars named: snd1, snd2, snd3…and so on.

My AS code is:  
[AS]  
//---------------------------------------------------  
//XML addition of external data  
//---------------------------------------------------  
var templateXML:XML = new XML();  
templateXML.ignoreWhite = true;  
templateXML.load(“safety.xml”);

templateXML.onLoad = function(p\_success:Boolean):Void  
{  
if(p\_success)  
{   
//Working on the sound array in the XML file.  
var xmlLen =templateXML.firstChild.childNodes[0].childNodes.length;

```
	for(i = 1; i &lt; xmlLen + 1; i++)
	{
	//trace(i + " worked.");
	snd* = "Sound " + i;
                  trace(snd*);
							
	}

}

```

}  
[/AS]

My XML file is:  
\<assets\>  
\<audios\>  
\<audio path=“audio/audio1.wav”/\>  
\<audio path=“audio/audio2.wav”/\>  
\<audio path=“audio/audio3.wav”/\>  
\<audio path=“audio/audio4.wav”/\>  
\<audio path=“audio/audio5.wav”/\>  
\<audio path=“audio/audio6.wav”/\>  
\<audio path=“audio/audio7.wav”/\>  
\<audio path=“audio/audio8.wav”/\>  
\<audio path=“audio/audio9.wav”/\>  
\<audio path=“audio/audio10.wav”/\>  
\</audios\>  
\</assets\>

I don’t know why I am getting an ‘undefined’ when I try to trace out the variable value.

Any help is appreciated.
