diff options
author | John Resig <jeresig@gmail.com> | 2006-08-13 15:15:15 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2006-08-13 15:15:15 +0000 |
commit | 7d4bf9725472b7684533a35e5fbd143c28a5758c (patch) | |
tree | 3cd28ec43588d5933e8fc39749b10f6e2b34de1f /build/js/xml.js | |
parent | 991390e2422d558cac2cfa5508fe3e921ac38e42 (diff) | |
download | jquery-7d4bf9725472b7684533a35e5fbd143c28a5758c.tar.gz jquery-7d4bf9725472b7684533a35e5fbd143c28a5758c.zip |
Moved some more of the build files around.
Diffstat (limited to 'build/js/xml.js')
-rw-r--r-- | build/js/xml.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/build/js/xml.js b/build/js/xml.js new file mode 100644 index 000000000..cc94eb750 --- /dev/null +++ b/build/js/xml.js @@ -0,0 +1,27 @@ +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 ) + if ( obj[i].constructor == Array || /</.test(obj[i] + "") || Object.toXML.force[i] ) + child += Object.toXML( obj[i], i ); + else + p += " " + i + "='" + (obj[i] + "").replace(/'/g, "'") + "'"; + + return "<" + tag + p + ( child ? ">\n" + child + "</" + tag + ">\n" : "/>\n" ); + } else if ( obj.constructor == String ) { + //obj = obj.replace(/</g,"<").replace(/>/g,">"); + //return "<" + tag + "><![CDATA[" + obj + "]]></" + tag + ">"; + return "<" + tag + ">" + obj + "</" + tag + ">\n"; + } + + return ""; +}; + +Object.toXML.force = {}; |