XML & DataGrid - Flash 8

I’m having trouble writing the proper loop to parse an xml file and populate a DataGrid.

For those XML nodes that have children, I’m trying to place them as an array into a single field of the DataGrid’s column.

My XML is structured as follows:


<shows>
    <Presentations name="FirstPresentation" version="edited">
        <slide type="swf" loadSize="normal">FirstSlide.swf</slide>
        <slide type="swf" loadSize="scale">SecondSlide.swf</slide>
    </Presntations>
    <Presentations name="SecondPresentation" version="full">
        <slide type="swf" loadSize="full">Blue.swf</slide>
        <slide type="swf" loadSize="normal" >Red.swf</slide>
    </Presntations>
</shows>

What I am trying to end up with a DataGrid in the following format:[INDENT][SIZE=1]**Presentation: **[/SIZE]
[SIZE=1]FirstPresentation[/SIZE]
[SIZE=1]*SecondtPresentation *[/SIZE]

[SIZE=1]Version:[/SIZE]
[SIZE=1]edited[/SIZE]
[SIZE=1]full[/SIZE]

[SIZE=1]Files:[/SIZE]
[SIZE=1]*FirstSlide.swf, SecondSlide.swf *[/SIZE]
[SIZE=1]*Blue.swf, Red.swf *[/SIZE]

[SIZE=1]type:[/SIZE]
[SIZE=1]swf, swf[/SIZE]
[SIZE=1]swf, swf[/SIZE]

[SIZE=1]LoadSize[/SIZE]
[SIZE=1]normal, scale[/SIZE]
[SIZE=1]full, normal[/SIZE]
[/INDENT]The files, type, and LoadSize fields would hold an array object of all childNodes and attributes for each Presentation node.

I was able to accomplish this in a similar app in which an additional DataGrid was first populated by parsing only the XML’s Presentation nodes into a list of presentation titles. Clicking on any one title would activate the following code and populate the second DataGrid - which is the one the user could sort through and edit.


//After loading & parsing XML file into the folling variable
//rawPresentations = this.firstChild.childNodes;
//And then populating a DataGrid with the name attribute of each Presentation node:
//
var fileArray = new Array();
var typeArray = new Array();
var loadSizeArray = new Array();

for (a = 0; a < rawPresentations.length; a++) {
    if (preSents[myIndex]["prezName"] == rawPresentations[a].attributes["presentName"]) {
        for (z = 0; z < rawPresentations[a].childNodes.length; z++) {
            fileArray.push(rawPresentations[a].childNodes[z].firstChild)
            typeArray.push(rawPresentations[a].childNodes[z].attributes["type"])
            loadSizeArray.push(rawPresentations[a].childNodes[z].attributes["loadSize"])
        } 
    selectedPresents.addItem({Name:rawPresentations[a].attributes["presentName"], Version: rawPresentations[a].attributes["version"], files: fileArray, type: typeArray, loadSize: loadSizeArray})
    delete fileArray
    delete typeArray
    delete loadSizeArray
    }
} 
myDataGrid.dataProvider = selectedPresents

The above code only works by individually parsing and adding each presentation element. What I need now is to populate a DataGrid with the entire contents of the XML file in one shot.

Any help very much appreciate as I have a deadline tomorrow - Thanks!

[SIZE=1]*[SIZE=1][SIZE=2]

[/SIZE]
[/SIZE]

*[/SIZE]