繁体   English   中英

JavaScript-IE 9 XML textContent

[英]JavaScript - IE 9 XML textContent

下一个代码在Firefox上运行良好,但是IE 9给出了udnefiend的结果:

var url = "http://www.w3schools.com/xml/note.xml";

var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange = function(event){ processRequest(event,xmlhttp); };
xmlhttp.send();

function processRequest(event,xmlhttp) {
    if(xmlhttp.readyState != 4) return;
    if(xmlhttp.status != 200) return;
    var responseXML = xmlhttp.responseXML;
    alert(responseXML.getElementsByTagName("note")[0].getElementsByTagName("to")[0].textContent);
}

如何在IE9中获取XML元素的textContent?

要从XML DOM对象访问任何节点的值,请使用属性

dom_node.nodeValue;

textContent不是W3C标准建议。 要求您使用跨浏览器兼容的标准属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM