# XML Parsing in AS Class...Root Node undefined

**URL:** <https://forum.kirupa.com/t/xml-parsing-in-as-class-root-node-undefined/167131>\
**Category:** flash\
**Created:** [October 25, 2005, 7:04pm UTC](https://forum.kirupa.com/t/xml-parsing-in-as-class-root-node-undefined/167131 "2005-10-25T19:04:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![panhead490](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@panhead490](https://forum.kirupa.com/u/panhead490)\
**Post date:** [October 25, 2005, 7:04pm UTC](https://forum.kirupa.com/t/xml-parsing-in-as-class-root-node-undefined/167131/1 "2005-10-25T19:04:25Z")

</div>

Upon parsing XML via an AS class called XMLMenu I created (an extension/modification to Senocular’s code), I want to save the root XML node/structure to use later.

Here is the relevant code:

```auto

 // class var to save root node to...
private var menuNode:XMLNode;

public function XMLMenu(xmlURL:String, container:MovieClip, x:Number, y:Number) {
	this.container = container;
	this.x = x;
	this.y = y;
		
	menuXML = new XML();
	menuXML.ignoreWhite = true;

	menu = container.createEmptyMovieClip("menu", container.getNextHighestDepth());
	submenu = menu.createEmptyMovieClip("submenu", menu.getNextHighestDepth());
		
	loadXML(xmlURL);
}

public function loadXML(xmlURL:String):Void {
	var menuClass:XMLMenu = this;
		
	menuXML.onLoad = function(success) {
		if (success) {
			menuClass.createMenu(menuClass.getX(), menuClass.getY(), this.firstChild, true);
			menuClass.menuNode = this.firstChild;
			trace("Menu Node: " + menuClass.menuNode);
		} else {
			//DIE
		}
	};
	menuXML.load(xmlURL);
}

public function getBoxNum(name:String):Number {
	trace("Menu Node: " + menuNode); // IT'S UNDEFINED HERE!
	return searchNodes(menuNode, "item", name);
}

```

I have access to the menu class in my loadXML procedure so I know that’s not the issue. But as soon as I get out of this method and try  
to refer to menuNode (in the getBoxNum() function), I get an undefined. What am I missing?

Thanks for the help,  
panhead490
