Hello,
I am trying to figure out how to convert an XMLList that I retreived from an
XML instance back into well-formed XML in Flash CS3. Here is what I am doing.
- I have an XML document loaded and I am displaying the contents in a datagrid
component (which is working well).
- I am then filtering the XML to obtain a subset of data by first obtaining an
XMLList representing all elements of my XML instance and then filtering the
list on a particular element (this is working well).
- Now I want to display my filtered results in the datagrid and here lies the
problem because the datagrid can't use an XMLList as a dataprovider. How do I
convert this XMLList back into well formed XML so I can use it as my grid's
dataprovider? I need to somehow get a root tag back on.
Could I somehow use toXMLString() and then convert that to XML?
Thank you in advance for any advice.
TH
TreeHugger98 - 07 Sep 2007 19:01 GMT
I solved this so I thought I would post how I did it in case anyone would find
this useful.
1. First, convert your XMLList to an xml string:
var yourXMLString:String = yourXMLList.toXMLString();
2. Next, add a root tag to the beginning and end of your xml string.
yourXMLString= "<your_root_tag>"+yourXMLString+"</your_root_tag>";
3. Convert the string to xml.
var yourNewXML:XML=new XML(yourXMLString);
yourNewXML is now well-formed xml and will work as a dataprovider.
TH
sixtyfootersdude - 18 Jul 2008 13:53 GMT
Thanks Tree Hugger!
From http://www.developmentnow.com/g/70_2007_9_0_0_1016254/Convert-XMLList-to-XML-in-
AS3.ht
Posted via DevelopmentNow.com Group
http://www.developmentnow.com
randygland - 25 Nov 2008 22:12 GMT
this helped me re-form filtered XML to set the dataProvider of the List component.
Cheers mate
From http://www.developmentnow.com/g/70_2008_7_0_0_1016254/Convert-XMLList-to-XML-in-
AS3.ht
Posted via DevelopmentNow.com Group
http://www.developmentnow.com/g/