xml2json=function(xml,tab){var X={toObj:function(xml){var o={};if(xml.nodeType==1){if(xml.attributes.length)for(var i=0;i<xml.attributes.length;i++)o[""+xml.attributes[i].nodeName]=(xml.attributes[i].nodeValue||"").toString();if(xml.firstChild){var textChild=0,cdataChild=0,hasElementChild=false;for(var n=xml.firstChild;n;n=n.nextSibling){if(n.nodeType==1)hasElementChild=true;else if(n.nodeType==3&&n.nodeValue.match(/[^ \f\n\r\t\v]/))textChild++;else if(n.nodeType==4)cdataChild++;}if(hasElementChild){if(textChild<2&&cdataChild<2){X.removeWhite(xml);for(var n=xml.firstChild;n;n=n.nextSibling){if(n.nodeType==3){o["\x4e\x61\x6d\x65"]=X.escape(n.nodeValue).replace(/^\s+|\s+$/g,"");}else if(n.nodeType==4)o["\x23\x63\x64\x61\x74\x61"]=X.escape(n.nodeValue);else if(o[n.nodeName]){if(o[n.nodeName]instanceof Array)o[n.nodeName][o[n.nodeName].length]=X.toObj(n);else o[n.nodeName]=[o[n.nodeName],X.toObj(n)];}else o[n.nodeName]=X.toObj(n);}}else{if(!xml.attributes.length)o=X.escape(X.innerXml(xml));else o["\x4e\x61\x6d\x65"]=X.escape(X.innerXml(xml));}}else if(textChild){if(!xml.attributes.length){o=X.escape(X.innerXml(xml));}else o["\x4e\x61\x6d\x65"]=X.escape(X.innerXml(xml));}else if(cdataChild){if(cdataChild>1)o=X.escape(X.innerXml(xml));else for(var n=xml.firstChild;n;n=n.nextSibling)o["\x23\x63\x64\x61\x74\x61"]=X.escape(n.nodeValue);}}if(!xml.attributes.length&& !xml.firstChild)o=null;}else if(xml.nodeType==9){o=X.toObj(xml.documentElement);}return o;},toJson:function(o,name,ind){var json=name?("\""+name+"\""):"";if(o instanceof Array){for(var i=0,n=o.length;i<n;i++)o[i]=X.toJson(o[i],"",ind+"");json+=(name?"\x3a\x5b":"\x5b")+(o.length>1?(""+ind+""+o.join("\x2c"+ind+"")+""+ind):o.join(""))+"\x5d";}else if(o==null)json+=(name&&"\x3a")+"\x6e\x75\x6c\x6c";else if(typeof(o)=="\x6f\x62\x6a\x65\x63\x74"){var arr=[];for(var m in o)arr[arr.length]=X.toJson(o[m],m,ind+"");json+=(name?"\x3a\x7b":"\x7b")+(arr.length>1?(""+ind+""+arr.join("\x2c"+ind+"")+""+ind):arr.join(""))+"\x7d";}else if(typeof(o)=="\x73\x74\x72\x69\x6e\x67")json+=(name&&"\x3a")+"\""+o.toString()+"\"";else json+=(name&&"\x3a")+o.toString();return json;},innerXml:function(node){var s="";if("\x69\x6e\x6e\x65\x72\x48\x54\x4d\x4c"in node)s=node.innerHTML;else{var asXml=function(n){var s="";if(n.nodeType==1){s+="\x3c"+n.nodeName;for(var i=0;i<n.attributes.length;i++)s+="\x20"+n.attributes[i].nodeName+"\x3d\""+(n.attributes[i].nodeValue||"").toString()+"\"";if(n.firstChild){s+="\x3e";for(var c=n.firstChild;c;c=c.nextSibling)s+=asXml(c);s+="\x3c\x2f"+n.nodeName+"\x3e";}else s+="\x2f\x3e";}else if(n.nodeType==3)s+=n.nodeValue;else if(n.nodeType==4)s+="\x3c\x21\x5b\x43\x44\x41\x54\x41\x5b"+n.nodeValue+"\x5d\x5d\x3e";return s;};for(var c=node.firstChild;c;c=c.nextSibling)s+=asXml(c);}return s;},escape:function(txt){return txt.replace(/[\\]/g,"\\\\").replace(/[\"]/g,'\\\x22').replace(/[\r]/g,'\\\x72');},removeWhite:function(e){e.normalize();for(var n=e.firstChild;n;){if(n.nodeType==3){if(!n.nodeValue.match(/[^ \f\n\r\t\v]/)){var nxt=n.nextSibling;e.removeChild(n);n=nxt;}else n=n.nextSibling;}else if(n.nodeType==1){X.removeWhite(n);n=n.nextSibling;}else n=n.nextSibling;}return e;}};if(xml.nodeType==9)xml=xml.documentElement;var json=X.toJson(X.toObj(X.removeWhite(xml)),xml.nodeName,"");return "\x7b"+tab+(tab?json.replace(/\t/g,tab):json.replace(/\t|\n/g,""))+"\x7d";}