Saturday, April 19, 2008

How to create XMLListCollection from XML in flex 3

There are times when the data that you obtain is in the form of XML or a string that contains XML tags. For displaying the data in datagrid, list, trees we desire to convert the data in the XMLListCollection. We need to perform the following steps to get the XMLListCollection.

1. Lets assume that we want to convert the following string to the XMLListCollection

var xmlStr:String="<root>

2. Convert the string to XML

private var pat:XML ;

pat=new XML(xmlstr);

3. Convert the XML to XMLList. We want to have individual persons as seperate XML objects

private var patList:XMLList;
patList = pat.person;

4. Convert the XMLList to XMLListCollection

private var patListCol:XMLListCollection;
patListCol = new XMLListCollection(patList);

In this way the XMLListCollection is created from the XML

1 comment:

ichsan anam said...

Thnak you very much for your sharing :)