var myXML:XML =
<order>
<item>
<menuName>burger</menuName>
<price>1. 95</price>
</item>
<item>
<menuName>burger</menuName>
<price>2. 95</price>
</item>
<item>
<menuName>burger</menuName>
<price>3. 95</price>
</item>
</order>;
private function XmlToArrayCollection(xml:XMLList):ArrayCollection{
var result:ArrayCollection = new ArrayCollection();
var xmlLength:int = xml.length();
for(var i:int = 0; i < xmlLength; i++){
var row:XMLList = xml[i].children();
var rowChildLength:int = row.length();
var resultRow:Object = {};
for(var j:int = 0 ; j < rowChildLength; j++){
resultRow[row[j].name()] = row[j];
}
result.addItem(resultRow);
}
return result;
}
private function toCollection():void{
Alert.show(ObjectUtil.toString(XmlToArrayCollection(myXML.item)));
}
<order>
<item>
<menuName>burger</menuName>
<price>1. 95</price>
</item>
<item>
<menuName>burger</menuName>
<price>2. 95</price>
</item>
<item>
<menuName>burger</menuName>
<price>3. 95</price>
</item>
</order>;
private function XmlToArrayCollection(xml:XMLList):ArrayCollection{
var result:ArrayCollection = new ArrayCollection();
var xmlLength:int = xml.length();
for(var i:int = 0; i < xmlLength; i++){
var row:XMLList = xml[i].children();
var rowChildLength:int = row.length();
var resultRow:Object = {};
for(var j:int = 0 ; j < rowChildLength; j++){
resultRow[row[j].name()] = row[j];
}
result.addItem(resultRow);
}
return result;
}
private function toCollection():void{
Alert.show(ObjectUtil.toString(XmlToArrayCollection(myXML.item)));
}