# Xml help

**URL:** <https://forum.kirupa.com/t/xml-help/260535>\
**Category:** Uncategorized\
**Created:** [May 16, 2008, 3:28pm UTC](https://forum.kirupa.com/t/xml-help/260535 "2008-05-16T15:28:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dj\_natlus](https://avatars.discourse-cdn.com/v4/letter/d/b5a626/32.png) [@Dj\_natlus](https://forum.kirupa.com/u/Dj_natlus)\
**Post date:** [May 16, 2008, 3:28pm UTC](https://forum.kirupa.com/t/xml-help/260535/1 "2008-05-16T15:28:11Z")

</div>

okay i make my xml code got that  
then i make a dynamic text field to load the info got that  
but how do i get it to load text ‘A’ for click on button a  
and text ‘B’ for button b?

---

<div class="post-metadata">

**Author:** ![shotymac](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@shotymac](https://forum.kirupa.com/u/shotymac)\
**Post date:** [May 21, 2008, 8:58pm UTC](https://forum.kirupa.com/t/xml-help/260535/2 "2008-05-21T20:58:12Z")

</div>

This would depend on how your xml is structured. The most common way would be to create an array to hold the data parsed from your xml and then assign that info to the array using a for loop. I have included a sample below, but again this is based on how your xml is structured. For simplicity of the explanation I have left out the xml object setup and load as I assume you know how to load xml into flash. If you need more help after this, upload your files and I will set it up for you with comments.

sample xml document:  
\<buttons\>  
\<button1 name=“Button1”\>  
\<text\>this is the text that you want to load on click\<text\>  
\<button1\>  
\<button2 name=“Button2”\>  
\<text\>this is the text that you want to load on click\<text\>  
\<button2\>  
\<buttons\>

Sample actionscrip 2.0 code  
//Create an array that will store the info parsed from the xml  
buttonDataArray:Array = new Array();

//This for loop will go inside of your xml load function  
var i:Number;  
for(i=0;i\<2; i++){  
buttonDataArray\* =myXml.firstChild.childNodes\*.childNodes[0].firstChild.nodeValue;  
}  
//On release the function will set the text  
myButtonA\_btn.onRelease = function(){  
myTextBoxA\_txt.text = buttonDataArray[0];  
}  
myButtonB\_btn.onRelease = function(){  
myTextBoxB\_txt.text = buttonDataArray[1];  
}

Hope this helps  
Sean
