2006-08-13 15:15:15 +00:00
|
|
|
Object.toXML = function( obj, tag ) {
|
|
|
|
if ( obj.constructor == Array ) {
|
|
|
|
var ret = "";
|
|
|
|
for ( var i = 0; i < obj.length; i++ )
|
|
|
|
ret += Object.toXML( obj[i], tag );
|
|
|
|
return ret;
|
|
|
|
} else if ( obj.constructor == Object ) {
|
|
|
|
var tag = tag || "tmp";
|
|
|
|
var p = "", child = "";
|
|
|
|
|
|
|
|
for ( var i in obj )
|
2006-09-01 05:52:26 +00:00
|
|
|
if ( ( obj[i].constructor != String && obj[i].constructor != Number ) || /</.test(obj[i] + "") || Object.toXML.force[i] )
|
2006-08-13 15:15:15 +00:00
|
|
|
child += Object.toXML( obj[i], i );
|
|
|
|
else
|
|
|
|
p += " " + i + "='" + (obj[i] + "").replace(/'/g, "'") + "'";
|
|
|
|
|
|
|
|
return "<" + tag + p + ( child ? ">\n" + child + "</" + tag + ">\n" : "/>\n" );
|
2006-09-01 05:52:26 +00:00
|
|
|
} else if ( obj.constructor == String || obj.constructor == Number ) {
|
2006-08-13 15:15:15 +00:00
|
|
|
return "<" + tag + ">" + obj + "</" + tag + ">\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
};
|
|
|
|
|
|
|
|
Object.toXML.force = {};
|