# Load XML by ID - Flash CS3, AS2

**URL:** <https://forum.kirupa.com/t/load-xml-by-id-flash-cs3-as2/298360>\
**Category:** flash\
**Created:** [October 17, 2009, 7:35am UTC](https://forum.kirupa.com/t/load-xml-by-id-flash-cs3-as2/298360 "2009-10-17T07:35:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![magapatalogikaa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/magapatalogikaa/32/3185_2.png) [@magapatalogikaa](https://forum.kirupa.com/u/magapatalogikaa)\
**Post date:** [October 17, 2009, 7:35am UTC](https://forum.kirupa.com/t/load-xml-by-id-flash-cs3-as2/298360/1 "2009-10-17T07:35:25Z")

</div>

I have to load a lot of information for 25 movies which load into a main SWF. And all the contents are loaded from a XML file.  
This comes from a client’s file already programmed in AS2 so I cannot use AS3 to load the XML which is a lot easier.

This is an example of my xml structure:  
\<root\>  
\<button\>  
\<btn1\>button 1\</btn1\>  
\<btn2\>button 2\</btn2\>  
\</button\>

```
&lt;movies&gt;
	&lt;movie id="slide1"&gt;
		&lt;title&gt;Slide n1&lt;/title&gt;
		&lt;text&gt;Conteúdo 1&lt;/text&gt;
	&lt;/movie&gt;

	&lt; movie id="slide2"&gt;
		&lt;title&gt;Slide n2&lt;/title&gt;
		&lt;text&gt;Conteúdo 2&lt;/text&gt;
                    &lt;image id="one"&gt;bicycle.jpg&lt;/image&gt;
	&lt;/movie &gt;
&lt; movies&gt;

```

\</root\>

There are about 25 slide nodes each with an ID. And each with a title, more than one text to load and some also have images.  
Is there a way that I call each slide by its ID, instead of having to write the entire code for the nodes?  
Right now I am using this AS2

my\_xml = new XML();  
my\_xml.ignoreWhite = true;  
my\_xml.onLoad = function(sucess) {  
if (sucess) {  
trace(my\_xml);  
}  
};  
// Load up the XML file into Flash  
my\_xml.load(‘modulo1.xml’);

// Load info for the buttons  
btn1 = my\_xml.firstChild.firstChild.childNodes[0].firstChild;  
btn2 = my\_xml.firstChild.firstChild.childNodes[1].firstChild;  
// Slide One  
\*\*\*\*lide1 = my\_xml.firstChild.firstChild.nextSibling.childNodes[0].firstChild.childNodes;  
txtslide1 =my\_xml.firstChild.firstChild.nextSibling.childNodes[0].firstChild.nextSibling.childNodes;

Coding it this way I will probably get lost along the way.  
If I could get the slides by ID it would be a lot easier and faster to code.
