# Loading XML

**URL:** <https://forum.kirupa.com/t/loading-xml/162464>\
**Category:** Uncategorized\
**Created:** [September 13, 2005, 4:26pm UTC](https://forum.kirupa.com/t/loading-xml/162464 "2005-09-13T16:26:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JordansGhost](https://avatars.discourse-cdn.com/v4/letter/j/c4cdca/32.png) [@JordansGhost](https://forum.kirupa.com/u/JordansGhost)\
**Post date:** [September 13, 2005, 4:26pm UTC](https://forum.kirupa.com/t/loading-xml/162464/1 "2005-09-13T16:26:55Z")

</div>

I am getting myself confused.

I am an absolute beginner with actionscript but not with coding in general.

I have used the following code to load an XML file in my movie on layer 1 frame 1

var getxmldata=new XML();  
getxmldata.load (“importantmessages.xml”,"");

The xml file is in the same directory as the .swf file and the .html file.

Then frame 2 - 30 is and animation showing a loading bar to give it time to load the XML file.

On frame 31 I have the following code.

if (getxmldata.loaded){  
var p = getxmldata.amountofnews;  
var amountofnews = p.news.newsitems;  
var currentnews = 0  
}else{  
gotoAndPlay(2);  
}

And on frame 32 this code

currentnews = currentnews + 1;  
if (currentnews \> amountofnews){  
currentnews = 1  
}  
var newstoload = “story” & currentnews;  
var n=getxmldata.newsstories;  
mainhead= n.headline;  
mainbody= n.bodytext;

now the flash file just loops round and never loads the XML. (it is not set to loop so it must be the code causing the loop).

I have no idea why.

Please help.
