2 Replies Latest reply on Aug 27, 2007 10:23 PM by sivudu

    converting mxml data to xml

    sivudu
      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();
      xml.appendChild(xml.createElement(nodeName));
      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);
      el.appendChild(xml.createTextNode(item));
      xml.firstChild.appendChild(el);
      } 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. Re: converting mxml data to xml
          batmitra Level 1
          hi
          what exactly are you trying to do?
          Because i don't understand why would you want to convert mxl to an xml file.
          • 2. Re: converting mxml data to xml
            sivudu Level 1
            Hi mitra,

            Thanx for ur reply. When I want to send complex data through httpservice the better way is , sending it througth xml . So I want to convert mxml data( means the data entered by user in UI developed based on flex ) to xml and after that I want to send it to file. have u any code to convert mxml data to xml. I tried the code that I have sent in my previous mail. But its not working. Could u help me to solve this issue.

            Thanks & Regards,
            Siva Kumar