Adobe Flex: Cannot Convert XMLList to mx.collections.IList

前端 未结 2 728
独厮守ぢ
独厮守ぢ 2021-01-24 19:42

My Flex app runs a service to a php page that pulls data from my database, then structures the result in an XML format. I created a new XMLList called testList outs

2条回答
  •  悲&欢浪女
    2021-01-24 20:11

    E4X expressions return lists of matching XML. xml.user gives you an XMLList of all user elements. You can use XMLListCollection, which implements IList, to wrap the result so you can use it as a dataprovider.

    var xml:XML = new XML(event.result as String);
    var list:IList = new XMLListCollection(xml.user);
    

    The other option is to loop though the XMLList and add it to an array or whatever collection you need. If you know for sure that there is only one user, you can do this instead:

    var user:XML = xml.user[0];
    

提交回复
热议问题