【转】两个小function实现XML和string相互转化
发布时间:2020-12-16 06:31:20 所属栏目:百科 来源:网络整理
导读:转自:http://www.cnblogs.com/Kymo/archive/2011/07/04/2097417.html //convert string to xml objectfunction String2XML(xmlString) { // for IE if (window.ActiveXObject) { var xmlobject = new ActiveXObject("Microsoft.XMLDOM"); xmlobject.async =
转自:http://www.cnblogs.com/Kymo/archive/2011/07/04/2097417.html
//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); } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |