Loading an XML file from another XML file in a list component

[FONT=Times New Roman][SIZE=3][COLOR=black]I’m sorry if I confused things with the long explanation of my problem. If you interested, see the text below. After working with the code, I found an easier way to explain my problem. I hope someone can help. [/COLOR][/SIZE][/FONT]

[SIZE=3][FONT=Times New Roman][COLOR=black]I have an external XML file:[/COLOR][/FONT][/SIZE]

[SIZE=3][FONT=Times New Roman][COLOR=black]<catagory>[/COLOR][/FONT][/SIZE][FONT=Times New Roman]
[SIZE=3][COLOR=black]<catsect>[/COLOR][/SIZE]
[SIZE=3][COLOR=black]<sorpage>012</sorpage>[/COLOR][/SIZE]
[SIZE=3][COLOR=black]<catpage>Air Cleaner</catpage>[/COLOR][/SIZE]
[SIZE=3][COLOR=black]</catsect>[/COLOR][/SIZE]
[SIZE=3][COLOR=black]</catagory>[/COLOR][/SIZE]

[SIZE=3]I have a function named “menuAction” that I’m trying to use to load “012” into a external variable called xmlFile. By external I mean outside the function. I have several iterations of <sorpage> in the XML doc that I want to assign to items in a list component called “my_list”.[/SIZE]

[SIZE=3]Here’s my code. [/SIZE]

[SIZE=3]var xmlFile:String;[/SIZE]

[SIZE=3]xmlLoader.load(new URLRequest(“data/xml/menutest.xml”)); //XML Source file[/SIZE]
[SIZE=3]function LoadXML(e:Event):void {[/SIZE]
[SIZE=3]xmlData = new XML(e.target.data);[/SIZE]
[SIZE=3]ParseList(xmlData);[/SIZE]
[SIZE=3]menuAction (xmlData);[/SIZE]
[SIZE=3]}[/SIZE]
[SIZE=3]function ParseList(listXML:XML):void {[/SIZE]
[SIZE=3]var listItem:XMLList = listXML.catsect.catpage;[/SIZE]
[SIZE=3]for each (var listTitle:XML in listItem) {[/SIZE]
[SIZE=3]my_list.addItem({label:listTitle,data:listTitle});[/SIZE]
[SIZE=3]} [/SIZE]
[SIZE=3]}[/SIZE]

[SIZE=3]my_list.addEventListener(MouseEvent.CLICK, ParseList);[/SIZE]

[SIZE=3]//mouse action for menu list[/SIZE]
[SIZE=3]function menuAction (listXML:XML):void {[/SIZE]
[SIZE=3]var linkItem:XMLList = listXML.catsect.sorpage;[/SIZE]
[SIZE=3]for each (var link:XML in linkItem){[/SIZE]
[SIZE=3]//link = xmlFile;[/SIZE]
[SIZE=3]trace(link);[/SIZE]
[SIZE=3]} [/SIZE]
[SIZE=3]}[/SIZE]
[/FONT]

[FONT=Times New Roman][SIZE=3]Long version—>[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Once again, I’m in over my head… Is there anyone that can steer me in a direction or give me some pointers?[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]I’m trying to pluck an element from one XML file and use it to load another XML file into a dataGrid component. I have a variable “var xmlFile:XMLList;” that I want to fill with the XML element . Then use that variable to load the DataGrid Component.[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]I’m using elements from the first XML file to propagate a List Component. Then when the user clicks on an item in the list, I want to fill the DataGrid component with a price list XML file. It seems so simple but my hair line is rapidly receding. The following is a fragment of my menu XML file (menutest.xml). <catpage> is the menu item loaded into the list component. <sorpage> is the name of the XML file loaded into the data grid.[/SIZE][/FONT]

[SIZE=3][FONT=Times New Roman]<catagory>[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]<catsect>[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]<sorpage>012</sorpage>[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]<catpage>Air Cleaner</catpage>[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]</catsect>[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]</catagory>[/FONT][/SIZE]

[FONT=Times New Roman][SIZE=3]At this point I have 4 functions:[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]LoadXML: loads my menutest XML file[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]ParseList: Populates my List Component with the text element of <catpage> from menutest.[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]dataGridHandler: formats the pricelist XML file in the datagrid component.[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]menuAction: (this is the problem) it’s supposed to take the text element of <sorpage>, load it into the variable xmlFile which the dataGridHandler used to determine which price list to load into the data grid when the item in the list component is clicked on.[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]From what I can tell, I’m not loading the variable xmlFile with the info from <sorpage>. The output window returns null.xml.[/SIZE][/FONT]

[SIZE=3][FONT=Times New Roman]my_list is the instance of the list component on stage. Here’s my code…[/FONT][/SIZE]

var xmlPath:String = “data/xml/”;
var xmlFile:XMLList;
var xmlType:String = “.xml”;
var priceListXML:XML;
var menuWords:String = “data/xml/menutest.xml”;
var fileType:String = “.jpg”;

//load list component
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest(“data/xml/menutest.xml”));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
ParseList(xmlData);
menuAction (xmlData);
}
function ParseList(listXML:XML):void {
var listItem:XMLList = listXML.catsect.catpage;
for each (var listTitle:XML in listItem) {
my_list.addItem({label:listTitle,data:listTitle});
}
}
//mouse action for menu list
function menuAction (listXML:XML):void {
var linkItem:XMLList = listXML.catsect.sorpage.text;
for each (var link:XMLList in linkItem){
xmlFile = linkItem;
trace(linkItem);
}
my_list.addEventListener(MouseEvent.CLICK, dataGridHandler);

}

//load XML from URL, Populate data grid
var request:URLRequest = new URLRequest(xmlPath + xmlFile + xmlType);
var loader:URLLoader=new URLLoader;
loader.load(request);
//loader.addEventListener(Event.COMPLETE, dataGridHandler);
function dataGridHandler(event:Event):void {
var pListXML:XML = new XML(loader.data);
var partCol:DataGridColumn = new DataGridColumn(“Part”);
partCol.headerText = “Part”;
partCol.width = 100;
var desCol:DataGridColumn = new DataGridColumn(“Description”);
desCol.headerText = “Description”;
desCol.width = 200;
var appCol:DataGridColumn = new DataGridColumn(“Application”);
appCol.headerText = “Application”;
appCol.width = 200;
var priceCol:DataGridColumn = new DataGridColumn(“Price”);
priceCol.headerText = “Price”;
priceCol.width = 100;
var myDP:DataGridColumn = new DataProvider(pListXML);
aDg.columns = [partCol, desCol, appCol, priceCol];
aDg.width = 755;
aDg.dataProvider = myDP;
}