2 Replies Latest reply on Apr 15, 2011 12:33 PM by Flex harUI

    Converting object to XML

    Zolotoj Level 3

      I am using the following code to convert an object into XML:

      public function objectToXML(obj:Object, qname:String="root"):XML 
                {
                     var qName:QName = new QName(qname);
                     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;
                }
      

       

      The resultant XML will have nodeName "item". Is it possible to customize it?

       

      Thanks