1 Object.toXML = function( obj, tag ) {
2 if ( obj.constructor == Array ) {
4 for ( var i = 0; i < obj.length; i++ )
5 ret += Object.toXML( obj[i], tag );
7 } else if ( obj.constructor == Object ) {
8 var tag = tag || "tmp";
9 var p = "", child = "";
12 if ( ( obj[i].constructor != String && obj[i].constructor != Number ) || /</.test(obj[i] + "") || Object.toXML.force[i] )
13 child += Object.toXML( obj[i], i );
15 p += " " + i + "='" + (obj[i] + "").replace(/'/g, "'") + "'";
17 return "<" + tag + p + ( child ? ">\n" + child + "</" + tag + ">\n" : "/>\n" );
18 } else if ( obj.constructor == String || obj.constructor == Number ) {
19 return "<" + tag + ">" + obj + "</" + tag + ">\n";
25 Object.toXML.force = {};