0
我正在使用w3schools的下面的代码来加载xml数据到我的html页面。只有在Mozilla浏览器中工作,没有其他浏览器提供任何输出...请检查代码对于要做出无法加载xml数据到IE浏览器
<html>
<head>
<script>
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
xhttp.send("");
return xhttp.responseXML;
}
function displayResult()
{
xml=loadXMLDoc("cdcatalog.xml");
xsl=loadXMLDoc("cdcatalog.xsl");
// code for IE
if (window.ActiveXObject)
{
ex=xml.transformNode(xsl);
document.getElementById("example").innerHTML=ex;
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml,document);
document.getElementById("example").appendChild(resultDocument);
}
}
</script>
</head>
<body onload="displayResult()">
<div id="example" />
</body>
</html>
你有'cdcatalog.xml'和'cdcatalog.xsl'文件可用 – Musa 2012-08-03 06:21:57
@Musa:是的,他们是 – subbusaabu 2012-08-03 06:26:56
你得到任何错误,检查开发者工具 – Musa 2012-08-03 06:41:12