1 Reply Latest reply on Aug 27, 2007 7:28 AM by levancho

    converting mxml data to xml

    sivudu Level 1
      Hi All,

      Anydody have the code to convert mxml data to .xml file. I have found this code in net.

      class XMLUtil {

      static function as2xml(obj: Object, nodeName: String) {
      var xml:XML=new XML();
      for (var i in obj) {
      handleItem(xml, obj , i);
      return xml;

      private static function handleItem(xml, item, nodeName: String) {
      var type=typeof item;
      if (type=="string" || type=="number" || item instanceof Date) {
      var el=xml.createElement(nodeName);
      } else if (item instanceof Array) {
      for(var i=0; i<item.length; i++)
      handleItem(xml, item
      , nodeName);
      } else if (item instanceof Object)
      xml.firstChild.appendChild(as2xml(item, nodeName));


      But its not working. I created relevant as files. Anybody have the code to convert to mxml data to xml like above.

      Thanks & Regards,
      Siva Kumar
        • 1. converting mxml data to xml
          levancho Level 3
          MXML is already an well formed XML document.(look at mxml files first line it says : <?xml version="1.0" encoding="utf-8"?> ) you cant convert from xml to xml(or to be more correct why do you need to convert from XMl to XML?), if you want to transform it use XSLT, but thats totally different story,
          what you are showing here is Action script to XMl convertor, and from this code its not obvious to see what is the problem since you are showing general util methods nothing concrete,