Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex String to XML

I have a string in XML format and I want to use this string as flex XML type as following :

This is my string :

<Graph>
   <Node id="1" name="1" nodeColor="0x333333" nodeIcon="center" x="10" y="10" />
   <Node id="2" name="2" nodeColor="0x333333" nodeIcon="center" x="10" y="10" />
   <Node id="3" name="3" nodeColor="0x333333" nodeIcon="center" x="10" y="10" />
</Graph>

I cant pass this to an API, it complains that this is string and it expects an XML type. How can i convert this string to XML with minimum effort, ie: without iterating the string and the nodes etc. Is there such method as : var data:XML = new XML(str:String);

How can i solve this?

like image 790
DarthVader Avatar asked Nov 08 '09 18:11

DarthVader


1 Answers

This blog entry suggests that the following would work:

var sText:String = "<your-xml-here />";
var xData:XML    = XML(sText);
like image 62
Tomalak Avatar answered Sep 23 '22 11:09

Tomalak