var arrSignatures=["MSXML2.DOMDocument.5.0","MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","Microsoft.XmlDom"]; 0;i
var oXmlDom=new ActiveXObject(arrSignatures[i]);
return oXmlDom;
} catch(oError){
}
throw new Error("MSXML is not installed on your system");
}
var oXmlDom=createXMLDOM();
//方式一:載入 oXmlDom=createXMLDOM();
//方式一:載入字串
oXmlDom.loadXML("
//處理錯誤
if(oXmlDom.parseError != 0){
var oError=oXmlDom.parseError; 🎜>alert("An Error occurred:nError Code:" oError.errorCode
"nLine:" oError.line "nLine Pos:" oError.linepos
"nReason:" oErrorson); else {
var childNodes=oXmlDom.documentElement.childNodes;
console.log(childNodes.length " " childNodes[0].xml);// 1
}
//方式二:載入XML檔
oXmlDom.onreadystatechange = function(){
//文件載入完畢
if(oXmlDom.readyState == 4){
if(oXmlDom.parseError != 00) {
var oError=oXmlDom.parseError;
alert("An Error occurred:nError Code:" oError.errorCode
"nLine:" oError.line "nLine Pospos: oLine Pospos"
var childNodes=oXmlDom.documentElement.childNodes;
console.log(childNodes.length " " childNodes[0].xml); child/>
}
}
}
oXmlDom.load("test.xml");
二、Mozilla中的XML DOM支援
1、創建DOM