我正在解析一个简单的XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" w:ocxPresent="no" w:embeddedObjPresent="no" w:macrosPresent="no">
<w:body>
<w:r>
<w:t>smpl tag txt</w:t>
</w:r>
</w:body>
</w:wordDocument>
以下代码在Chrome和IE11中运行良好,但在IE8中运行不正常,因为不支持getElementsByTagNameNS。
<html>
<body>
<script>
xhttp=new XMLHttpRequest();
xhttp.open("GET", "smpl.xml", false);
xhttp.send();
xml = xhttp.responseXML;
x = xml.getElementsByTagNameNS('http://schemas.microsoft.com/office/word/2003/wordml', 't');
document.write(x[i].childNodes[0].nodeValue);
</script>
</body>
</html>
是否有替代getElementsByTagNameNS来处理IE8中的命名空间?