Sometimes, loading xml gives a "undefined" message?

Hi,

Been a while and i have AS2 file which loads a .xml file. It works but not all the time. Without changing anything just refreshing the browser i get a undefined in the textfields. How can i make sure the xml is loaded?

I use the following AS


var xmlPath:String = "/quotes.xml";
var xml:XML = new XML();
xml.ignoreWhite = true;

xml.onLoad = function(success) {
	if (success) {
			var nodes= this.firstChild.firstChild.childNodes;
			numOfItems = nodes.length;
			
			for(i=0;i<numOfItems;i++) {
				var item = nodes*;
				quotes.push(nodes*.firstChild.childNodes);
				authors.push(item.lastChild.childNodes);
			}
	} else {
		gotoandplay(10);
	}
}
//xml.load(xmlPath+"?nocache="+getTimer());
xml.load(xmlPath);

and on frame 10 i have the follow init function to get a random quote

function init(){
	//random number
	var randomSelection = Math.floor((Math.random() * myQuotes.length));
	var quote =  myQuotes[randomSelection];
	var auth = myAuthors[randomSelection];
	trace(randomSelection);
	showQuote(quote,auth);
	myQuotes.splice(randomSelection, 1);
	if(myQuotes.length == 0) {
		myQuotes = quotes.slice();
	}
	myAuthors.splice(randomSelection, 1);
	if(myAuthors.length == 0) {
		myAuthors = authors.slice();
	}
}