Loading XML

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

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.