/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public static function objectToXML(obj:Object):XML { var qName:QName = new QName("root"); var xmlDocument:XMLDocument = new XMLDocument(); var simpleXMLEncoder:SimpleXMLEncoder = new SimpleXMLEncoder(xmlDocument); var xmlNode:XMLNode = simpleXMLEncoder.encodeValue(obj, qName, xmlDocument); var xml:XML = new XML(xmlDocument.toString()); return xml; } //or arraycollection: public static function objectToXML(obj:ArrayCollection):XML { var qName:QName = new QName("root"); var xmlDocument:XMLDocument = new XMLDocument(); var simpleXMLEncoder:SimpleXMLEncoder = new SimpleXMLEncoder(xmlDocument); var xmlNode:XMLNode = simpleXMLEncoder.encodeValue(obj, qName, xmlDocument); var xml:XML = new XML(xmlDocument.toString()); return xml; }