faster way to change xml to array(grails to flex)

Posted by Anthony Umpad on Stack Overflow See other posts from Stack Overflow or by Anthony Umpad
Published on 2010-04-22T01:50:18Z Indexed on 2010/04/22 1:53 UTC
Read the original article Hit count: 362

Filed under:
|
|
|

I have a large xml passed from grails to flex. When flex receives the xml, it converts the xml into an associative array object. Given the large xml file, it takes too long to complete the loop, is there any way in flex to make conversion faster? Below is my sample code.

<xml>
   <car>
      <model>Vios</model>
      <type>Sedan</type>
      <color>Blue</color>
   </car>
   <car>
      <model>Camry</model>
      <type>Luxury</type>
      <color>Black</color>
   </car>
</xml>

*converted to the flex associative array below.*
[Vios].type = Sedan
      .color = Blue
[Camry].type = Luxury
       .color = Black

*Below is a code I used in flex to convert the xml to the associative array object*
var tempXML=xml.children()
var tempArray:Array= new Array()
for(var i:int=0;i<tempXML.length();i++)
{
   tempArray[tempXML[i].@model]= new Object();
   tempArray[tempXML[i].@model].color = tempXML[i][email protected]();
   tempArray[tempXML[i].@model].type = tempXML[i][email protected]();
}

© Stack Overflow or respective owner

Related posts about grails

Related posts about flex