解析xml 在IE下是对的 在Chrom下是错的 为什么???
看代码
- JScript code
function loadXML(url){ var xmldoc = null; if (document.implementation && document.implementation.createDocument) { xmldoc = document.implementation.createDocument("","",null); xmldoc.async = false; xmldoc.load(url); } else if(window.ActiveXObject) { xmldoc = new ActiveXObject("Microsoft.XMLDOM"); xmldoc.async = false; xmldoc.load(url); } if (xmldoc != null) { if (xmldoc.parseError.errorCode != 0) { alert(xmldoc.parseError.reason); return null; } } return xmldoc;}function makeBuildHtmlContent(type){//写构建步骤那块 var xmldoc = loadXML("SCRequestCfg.xml"); if (xmldoc == null) { alert("Load Xml failed\n"); return null; } var root = null; root = document.getElementById(type); if(root == null) { alert("load build root failed\n"); return null; } var table = document.createElement('table'); table.setAttribute("border","1"); root.appendChild(table); var header = table.createTHead(); var headerrow = header.insertRow(0); headerrow.insertCell(0).appendChild(document.createTextNode("构建名称")); headerrow.insertCell(1).appendChild(document.createTextNode("权限级别")); headerrow.insertCell(2).appendChild(document.createTextNode("预估耗时")); headerrow.insertCell(3).appendChild(document.createTextNode("超时时间")); headerrow.insertCell(4).appendChild(document.createTextNode("是否涉及加壳")); ......//后面的逻辑就不写了 就是更具xml里的内容动态创建一个表格}
在Html是这么调用的 就是给div里根据xml内容填充东西 在IE8下显示正常 在chrome下就错了
- JScript code
<body onload="makeBuildHtmlContent('safebox_build_steps_all')"> <div id="wrapper"> <div id="safebox_build_steps_all"> </div> </div></body>
[解决办法]
请使用XMLRequestHttp实现,不要使用XMLDOM