Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Chrome和IE不显示XML文件中的标记值_Javascript_Html_Xml_Internet Explorer_Google Chrome - Fatal编程技术网

Javascript Chrome和IE不显示XML文件中的标记值

Javascript Chrome和IE不显示XML文件中的标记值,javascript,html,xml,internet-explorer,google-chrome,Javascript,Html,Xml,Internet Explorer,Google Chrome,我有以下HTML代码: <html> <body> <h1>W3Schools Internal Note</h1> <div> <b>To:</b> <span id="to"></span><br /> <b>From:</b> <span id="from"></span><br /> <b>Mes

我有以下HTML代码:

<html>
<body>
<h1>W3Schools Internal Note</h1>
<div>
 <b>To:</b> <span id="to"></span><br />
<b>From:</b> <span id="from"></span><br />
<b>Message:</b> <span id="message"></span>
</div>

<script type="text/javascript">
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
   xmlhttp=new XMLHttpRequest();
 }
else
 {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","languages.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

document.getElementById("to").innerHTML=
 xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
document.getElementById("from").innerHTML=
xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
document.getElementById("message").innerHTML=
xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
</script>

</body>
</html>

学校内部说明
致:
发件人:
信息: if(window.XMLHttpRequest) {//IE7+、Firefox、Chrome、Opera、Safari的代码 xmlhttp=新的XMLHttpRequest(); } 其他的 {//IE6、IE5的代码 xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”); } open(“GET”,“languages.xml”,false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; document.getElementById(“to”).innerHTML= xmlDoc.getElementsByTagName(“to”)[0].childNodes[0].nodeValue; document.getElementById(“from”).innerHTML= xmlDoc.getElementsByTagName(“from”)[0]。子节点[0]。节点值; document.getElementById(“消息”).innerHTML= xmlDoc.getElementsByTagName(“主体”)[0].childNodes[0].nodeValue;
这段代码在Firefox中有效,但在Chrome和IE中不起作用。我的意思是Firefox显示了XML文档中XML标记的结果,而Chrome和IE则不是!!!
请帮助我。

尝试在所有元素上用
textContent
替换
nodeValue
。如果这不是解决方案,请发布您的XML。

1)同步AJAX调用是个坏主意。2) 停止使用学校: