Hi,
I have a XMLLIstCollection and I coverted the XMLLIstCollection to String(XMLLIstCollection.toString()) and send it to database. Similarky, I would like to receive the stored string value from the database and show it in Tree. For this, I am trying to convert the String to XMLListCollection(StringVariable as XMLListCollection) and it has null value.
It it possible to typecast/convert a String to XMLListCollection?
Thanks!
Convert String to XMLListCollectionThis example answers your question. Note how I cast the string to an XMLList, and then use e4x syntax to extract the XML data to populate the XMLListCollection.
If this post answers your question or helps, please mark it as such.
%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:Application xmlns:mx=''http://www.adobe.com/2006/mxml''
聽 creationComplete=''init();''%26gt;
聽 %26lt;mx:Script%26gt;
聽聽聽 %26lt;![CDATA[
聽聽聽聽聽 import mx.collections.XMLListCollection;
聽聽聽聽聽 private var strXML:String = ''%26lt;myData%26gt;%26lt;item%26gt;%26lt;fname%26gt;Bob%26lt;/fname%26gt;%26lt;lname%26gt;Smith%26lt;/lname%26gt;%26lt;/item%26gt;%26lt;item%26gt;%26lt;fname%26gt;Tim%26lt;/f name%26gt;%26lt;lname%26gt;Carson%26lt;/lname%26gt;%26lt;/item%26gt;%26lt;item%26gt;%26lt;fname%26gt;Jon%26lt;/fname%26gt;%26lt;lname%26gt;Casey%26lt;/lname%26gt;%26lt;/i tem%26gt;%26lt;/myData%26gt;'';
聽聽聽聽聽 [Bindable] private var xlc:XMLListCollection;
聽聽聽聽聽
聽聽聽聽聽 private function init():void{
聽聽聽聽聽聽聽 xlc = new XMLListCollection(XMLList(strXML)..item);
聽聽聽聽聽 }
聽聽聽 ]]%26gt;
聽 %26lt;/mx:Script%26gt;
聽 %26lt;mx:DataGrid dataProvider=''{xlc}''%26gt;
聽聽聽 %26lt;mx:columns%26gt;
聽聽聽聽聽 %26lt;mx:DataGridColumn dataField=''fname''/%26gt;
聽聽聽聽聽 %26lt;mx:DataGridColumn dataField=''lname''/%26gt;
聽聽聽 %26lt;/mx:columns%26gt;
聽 %26lt;/mx:DataGrid%26gt;
%26lt;/mx:Application%26gt;
No comments:
Post a Comment