[flexcoders] converting mxml data to xml code
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], 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; iitem.length; i++) handleItem(xml, item[i], 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
Re: [flexcoders] converting mxml data to xml code
Not working how? - Dan On 8/27/07, siva.flex [EMAIL PROTECTED] wrote: 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], 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; iitem.length; i++) handleItem(xml, item[i], 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