faster way to change xml to array(grails to flex)
- by Anthony Umpad
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]();
}