# Flash XML What am I doing wrong, please help!

**URL:** <https://forum.kirupa.com/t/flash-xml-what-am-i-doing-wrong-please-help/274569>\
**Category:** Uncategorized\
**Created:** [October 31, 2008, 4:23pm UTC](https://forum.kirupa.com/t/flash-xml-what-am-i-doing-wrong-please-help/274569 "2008-10-31T16:23:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![crapitoutjim](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@crapitoutjim](https://forum.kirupa.com/u/crapitoutjim)\
**Post date:** [October 31, 2008, 4:23pm UTC](https://forum.kirupa.com/t/flash-xml-what-am-i-doing-wrong-please-help/274569/1 "2008-10-31T16:23:16Z")

</div>

Hi There,  
I am trying to get a movie clip to pop up when i press a button, when the clip pops up it displays certain information taken from an xml document. I want to be able to display the info held in the first part of the xml to display when i press the 1st button, the info in the 2nd part of the xml to display when i press the 2nd button and so on. However it always seems to loop to the last item in the xml list. I have attached a simplified version of my problem to this posting, please help me someone I am going mad trying to get it to work. I have also posted my actionscript code below:

import mx.xpath.XPathAPI;

var popup\_xml:XML = new XML();  
var popupArray:Array = new Array;  
var popupNames:Array = new Array;

popup\_xml.ignoreWhite = true;  
popup\_xml.onLoad = popUpFunction;  
popup\_xml.load(“xml/popup.xml”);

var popupPath:String = “/content/products/pop”;

function popUpFunction(success:Boolean) {  
if (success) {  
popupArray = XPathAPI.selectNodeList(this.firstChild, popupPath);  
popupBuilder(popupArray);  
} else {  
trace(“Error: XML not successfully loaded”);  
}  
};

function popupBuilder(popupArray) {  
for (var i:Number = 0; i\<popupArray.length; i++) {  
var imageName:String;  
imageName = popupArray\*.childNodes[0].firstChild;  
var titleName:String;  
titleName = popupArray\*.childNodes[1].firstChild;  
var mainBody:String;  
mainBody = popupArray\*.childNodes[2].firstChild;

```
	image_mc.loadMovie(imageName);
	title_txt.htmlText = titleName;
	body_txt.htmlText = mainBody;
}

```

}

Thanks

James
