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
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
From http://www.developmentnow.com/g/70_2007_9_0_0_1016254/Convert-XMLList-to-XML-in-AS3.htm
Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Cheers mate
:D
From http://www.developmentnow.com/g/70_2008_7_0_0_1016254/Convert-XMLList-to-XML-in-AS3.htm
Posted via DevelopmentNow.com Groups
http://www.developmentnow.com/g/
var newXML:XML = <your_root_tag/>
newXML.appendChild (yourXMLList);
Or even better, this works too:
var newXML:XML = <your_root_tag>{yourXMLList}</your_root_tag>;
From http://www.developmentnow.com/g/70_2008_11_0_0_1016254/Convert-XMLList-to-XML-in-AS3.htm
new XML( node.toXMLString() );
Thank you again!!! ;D
From http://www.developmentnow.com/g/70_2009_8_0_0_1016254/Convert-XMLList-to-XML-in-AS3.htm