function SoftXpath(){var xmljson;this.loadXML=function(e,t,a){t&&a.logEvent("loadXML: start",!0),e=e.replace(/<\?[^>]*>/g,"").replace(/<\![^>]*>/g,"");var l=e.substring(1,e.indexOf(">"));return xmljson=xml2json.parser(e,t,a)[l]},this.selectNodes=function(xpath){var toeval,i,results=[];if("//*/"===xpath.substring(0,4))toeval="xmljson"+xpath.substring(3).replace(/\//g,".");else{if("*"===xpath.substring(2,1))return console.log("SoftXpath2: unhandled query style: "+xpath),results;toeval="xmljson"+xpath.substring(xpath.lastIndexOf("/")).replace(/\//g,".")}var tail=toeval.substring(toeval.lastIndexOf(".")+1),text,mexml;try{var branch=eval(toeval);if("undefined"!=typeof branch)if(null===branch)results[results.length]={nodeName:tail,text:"",me:{xml:"<"+tail+"/>"}};else if("object"==typeof branch)if(branch.length)for(i=0;i<branch.length;i++)null===branch[i]?(text="",mexml="<"+tail+"/>"):"object"==typeof branch[i]?(text="NA",mexml="<"+tail+">"+this.json2xml(branch[i])+"</"+tail+">"):(text=this.textUnescape(branch[i]),mexml="<"+tail+">"+branch[i]+"</"+tail+">"),results[results.length]={nodeName:tail,text:text,me:{xml:mexml}};else text="NA",mexml="<"+tail+">"+this.json2xml(branch)+"</"+tail+">",results[results.length]={nodeName:tail,text:text,me:{xml:mexml}};else mexml="<"+tail+">"+branch+"</"+tail+">",results[results.length]={nodeName:tail,text:this.textUnescape(branch),me:{xml:mexml}}}catch(e1){}return results},this.textUnescape=function(e){return e=e.replace(/&amp;amp;/g,"§amp;amp;"),e=e.replace(/&amp;apos;/g,"§amp;apos;"),e=e.replace(/&amp;lt;/g,"§amp;lt;"),e=e.replace(/&amp;gt;/g,"§amp;gt;"),e=e.replace(/&amp;quot;/g,"§amp;quot;"),e=e.replace(/&amp;/g,"&"),e=e.replace(/&apos;/g,"'"),e=e.replace(/&lt;/g,"<"),e=e.replace(/&gt;/g,">"),e=e.replace(/&quot;/g,'"'),e=e.replace(/§amp;amp;/g,"&amp;amp;"),e=e.replace(/§amp;apos;/g,"&amp;apos;"),e=e.replace(/§amp;lt;/g,"&amp;lt;"),e=e.replace(/§amp;gt;/g,"&amp;gt;"),e=e.replace(/§amp;quot;/g,"&amp;quot;"),e=e.replace(/&amp;/g,"&")},this.json2xml=function(e,t){var a=function(e,t,l){var r="";if(e instanceof Array)for(var n=0,s=e.length;s>n;n++)r+=l+a(e[n],t,l)+"\n";else if("object"==typeof e){var p=!1;r+=l+"<"+t;for(var m in e)"@"==m.charAt(0)?r+=" "+m.substr(1)+'="'+e[m].toString()+'"':p=!0;if(r+=p?">":"/>",p){for(m in e)"#text"==m?r+=e[m]:"#cdata"==m?r+="<![CDATA["+e[m]+"]]>":"@"!=m.charAt(0)&&(r+=a(e[m],m,l));r+=("\n"==r.charAt(r.length-1)?l:"")+"</"+t+">"}}else r+=l+"<"+t+">"+e.toString()+"</"+t+">";return r},l="";for(var r in e)e.hasOwnProperty(r)&&(l+=t?a(e[r],t,""):a(e[r],r,""));return l}}