Flex String for XML

I have a string in XML format and I want to use this string as a flexible XML type, as shown below:

This is my line:

<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 cannot pass this API, it complains that it is a string, and it expects an XML type. How can I convert this string to XML with minimal effort, that is: without repeating the string and nodes, etc. Is there such a method as: var data: XML = new XML (str: String);

How can i solve this?

+6
string flex xml
source share
2 answers

This blog post assumes the following will work:

 var sText:String = "<your-xml-here />"; var xData:XML = XML(sText); 
+12
source share

To add Tomalak's comment, you can also simply define:

 var xData:XML = <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>; 
+4
source share

All Articles