Moved some more of the build files around.
[jquery.git] / build / js / xml.js
1 Object.toXML = function( obj, tag ) {
2   if ( obj.constructor == Array ) {
3     var ret = "";
4     for ( var i = 0; i < obj.length; i++ )
5       ret += Object.toXML( obj[i], tag );
6     return ret;
7   } else if ( obj.constructor == Object ) {
8     var tag = tag || "tmp";
9     var p = "", child = "";
10
11     for ( var i in obj )
12       if ( obj[i].constructor == Array || /</.test(obj[i] + "") || Object.toXML.force[i] )
13         child += Object.toXML( obj[i], i );
14       else
15         p += " " + i + "='" + (obj[i] + "").replace(/'/g, "&apos;") + "'";
16
17     return "<" + tag + p + ( child ?  ">\n" + child + "</" + tag + ">\n" : "/>\n" );
18   } else if ( obj.constructor == String ) {
19     //obj = obj.replace(/&lt;/g,"<").replace(/&gt;/g,">");
20     //return "<" + tag + "><![CDATA[" + obj + "]]></" + tag + ">";
21     return "<" + tag + ">" + obj + "</" + tag + ">\n";
22   }
23
24   return "";
25 };
26
27 Object.toXML.force = {};