xml文件:
<statistical value="loudi" label="娄底">
<statistical value="00" label="全口径"></statistical>
<statistical value="01" label="部署口径"></statistical>
</statistical>
<statistical value="hengyang" label="衡阳">
<statistical value="00" label="地市公司"></statistical>
<statistical value="01" label="直供"></statistical>
<statistical value="02" label="泵售结算"></statistical>
<statistical value="03" label="县公司"></statistical>
</statistical>
</statisticalList>
</statisticals>
AS解析程序:
public class StatisticalUtil
{
public static var statisticalArr:ArrayCollection=new ArrayCollection();
public static var viewXMLList:XMLList=new XMLList();
public function StatisticalUtil()
{
}
public static function getStatistical():void{
var hts:HTTPService = new HTTPService();
hts.url="assets/data/statistical.xml";
hts.resultFormat="e4x";
hts.addEventListener(ResultEvent.RESULT,handler);
hts.send();
}
private static function handler(e:ResultEvent):void{
//statisticalArr=e.result as ArrayCollection;
viewXMLList = e.result.statisticalList;
var oList:Object=new Object();
oList=viewXMLList[0].statistical;
for(var i:int=0;i<oList.length();i++){
//log.debug(menuObj[i].@title)
var o:Object=new Object();
o.value=oList[i].@value
o.label=oList[i].@label
o.children=new ArrayCollection()
var childObj:Object=oList[i].statistical
for(var j:int=0;j<childObj.length();j++){
var o1:Object=new Object();
o1.value=childObj[j].@value
o1.label=childObj[j].@label
o.children.addItem(o1)
}
statisticalArr.addItem(o)
}
}
}
}