Posted in Javascript onJuly 04, 2011
//convert string to xml object function String2XML(xmlString) { // for IE if (window.ActiveXObject) { var xmlobject = new ActiveXObject("Microsoft.XMLDOM"); xmlobject.async = "false"; xmlobject.loadXML(xmlstring); return xmlobject; } // for other browsers else { var parser = new DOMParser(); var xmlobject = parser.parseFromString(xmlstring, "text/xml"); return xmlobject; } } //convert xml object to string function XML2String(xmlObject) { // for IE if (window.ActiveXObject) { return xmlobject.xml; } // for other browsers else { return (new XMLSerializer()).serializeToString(xmlobject); } }
JavaScript XML和string相互转化实现代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@