[英]Windows 8 javascript html5 app not parsing xml
当我使用本地HTML和XML文件将它加载到firefox中时,我的javascript XML解析代码可以正常工作,但是当我使用相同的代码在visual studio 2012(HTML5 javascript应用程序)中构建应用程序时,它无法解析XML文件。
<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", "pages/home/example.xml", false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
//Content
txt = xmlDoc.getElementsByTagName("Symbol")[0].childNodes[0].nodeValue;
document.write(txt + " ");
您只能在加载后获取responseXML。
var xmlDoc
xmlhttp.open("GET", "pages/home/example.xml", false);
xmlhttp.onload = function(){
xmlDoc = xmlhttp.responseXML
}
xmlhttp.send();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.