轉載請註明來源:js字串轉換成xml並使用
print?//字串轉換為xml
function toXmlDom(source){ var xmlDoc = null; if (window.ActiveXObject) { var ARR_ACTIVEX =
["MSXML4.DOMDocument","MSXML3.DOMDocument","MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XmlDom"]; var XmlDomflag = false; for (var i = 0;i < ARR_ACTIVEX.length && !XmlDomflag ;i++) { try { var objXML = new ActiveXObject(ARR_ACTIVEX[i]); xmlDoc = objXML; XmlDomflag = true; } catch (e) { } } if (xmlDoc) { xmlDoc.async = false; xmlDoc.loadXML(source); } }else{ var parser=new DOMParser(); var xmlDoc=parser.parseFromString(source,"text/xml"); } return xmlDoc; }
網
就是使用相同內容.