# Dynamic array index names

**URL:** <https://forum.kirupa.com/t/dynamic-array-index-names/266087>\
**Category:** flash\
**Created:** [July 16, 2008, 5:16am UTC](https://forum.kirupa.com/t/dynamic-array-index-names/266087 "2008-07-16T05:16:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephenr85](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@stephenr85](https://forum.kirupa.com/u/stephenr85)\
**Post date:** [July 16, 2008, 5:16am UTC](https://forum.kirupa.com/t/dynamic-array-index-names/266087/1 "2008-07-16T05:16:52Z")

</div>

I’m creating an extension of the DataProvider class that receives XML and converts it to a DataProvider automatically. This will simplify sorting XML and binding it to acceptable objects, like a DataGrid.

Where I’m stuck is creating a dynamic array with index names matching the node names. Here’s what I have:

```auto

//get the column names
for(var i=0;i<xml[0].children()[0].children().length();i++){
    xmlColumns.push(xml[0].children()[0].children()*.name());
}
//populate the dataprovider
for(i=0; i < xml[0].children().length(); i++){
    var currentNode = xml[0].children()*;
    var currentArray = new Array();

    for(var m=0; m < xmlColumns.length; m++){
        var nodeName:String = currentNode.children()[m].name();
        currentArray.push({nodeName:currentNode.children()[m]});
    }
    trace(currentArray);
    this.addItem(currentArray);
}

```

Notice the nodeName variable I am trying to use as the alias for the columns. I’ve tried this several ways:

```auto

currentArray.push({nodeName:currentNode.children()[m]});
currentArray.push({this[nodeName]:currentNode.children()[m]});
currentArray.push({String(nodeName):currentNode.children()[m]});
currentArray.push({nodeName.toString():currentNode.children()[m]});
currentArray.push({$nodeName:currentNode.children()[m]});
currentArray.push({%nodeName%:currentNode.children()[m]});
currentArray[m][nodeName]=currentNode.children()[m];

```

I think I’m going to kick myself when I found out what to do here, but quite a few google searches have not yielded much either…

I really appreciate any help.

Thanks,  
Stephen
