/* This work is licensed under Creative Commons GNU LGPL License. License: http://creativecommons.org/licenses/LGPL/2.1/ Version: 0.9 Author: Stefan Goessner/2006 Web: http://goessner.net/ */ function json2xml(o, tab) { var toXml = function(v, name, ind) { var xml = ""; if (v instanceof Array) { for (var i=0, n=v.length; i" : "/>"; if (hasChild) { for (var m in v) { if (m == "#text") xml += v[m]; else if (m == "#cdata") xml += ""; else if (m.charAt(0) != "@") xml += toXml(v[m], m, ind+"\t"); } xml += (xml.charAt(xml.length-1)=="\n"?ind:"") + ""; } } else { xml += ind + "<" + name + ">" + v.toString() + ""; } return xml; }, xml=""; for (var m in o) xml += toXml(o[m], m, ""); return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, ""); }