# XML to ArrayCollection for DataGrid binding

**URL:** <https://forum.kirupa.com/t/xml-to-arraycollection-for-datagrid-binding/256928>\
**Category:** flash\
**Created:** [April 8, 2008, 9:39pm UTC](https://forum.kirupa.com/t/xml-to-arraycollection-for-datagrid-binding/256928 "2008-04-08T21:39:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![colorful\_tones](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/colorful_tones/32/3009_2.png) [@colorful\_tones](https://forum.kirupa.com/u/colorful_tones)\
**Post date:** [April 8, 2008, 9:39pm UTC](https://forum.kirupa.com/t/xml-to-arraycollection-for-datagrid-binding/256928/1 "2008-04-08T21:39:26Z")

</div>

I want to get my XML into a DataGrid, but I’m not sure of the best method?  
Here is where my XML is being set:

```auto
   private function resultHandler(event:ResultEvent):void
            {
                var str:String = event.result.toString();
                var arr:Array = str.split('&');
                var xml:XML = <multimedia/>;
                var xn:XML = <item/>;
                var a:Array;
                for(var i:int=0; i<arr.length; i++){
                    a = arr*.split(',');
                    xn = <item/>;
                    for each(var s:String in a){
                        xn.appendChild(pairToXML(s));
                    }
                    xml.appendChild(xn);
                }
                function pairToXML(st:String):XML {
                var xn:XML = <foo/>;
                var xs:Array = st.split('=');
                xn[xs[0]] = xs[1];
                return xn[xs[0]][0];
                }
                **trace(xml.toXMLString());**
            }

```

so that my **trace** is=

```auto
<multimedia>
  <item>
    <uniqueid>1</uniqueid>
    <mm_name>bluehills.jpg</mm_name>
    <mm_path>img/req1</mm_path>
    <mm_keywords>keyword1</mm_keywords>
  </item>
  <item>
    <uniqueid>2</uniqueid>
    <mm_name>satellite_map.jpg</mm_name>
    <mm_path>img/req2</mm_path>
    <mm_keywords>map satellite</mm_keywords>
  </item>
  <item>
    <uniqueid>3</uniqueid>
    <mm_name>robot.jpg</mm_name>
    <mm_path>img/req2</mm_path>
    <mm_keywords>robot black and white</mm_keywords>
  </item>
</multimedia>

```

do I have to put this into an ArrayCollection for easy DataGrid binding? and how? any suggestions?
