我已经为跨平台应用程序加载了一个 xml。它在 android 中运行,在windows 手机中运行 ios 位失败。我在同一个文件夹中有 html 和 xml。
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load('BranchDetail.xml');
var xmlrows = xmlDoc.getElementsByTagName("ROW");
alert(xmlrows.length);
此方法适用于 IE 10 桌面浏览器。我在 android 和 Iphone 中使用 xmlhttp 请求方法。xmlhttp 请求方法在 WP8 IE10 中也不起作用
我也尝试将 xmlDoc = new ActiveXObject("Microsoft.XMLHTTP") 用于 WP IE 10。
用于android和ios的方法:
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "BranchDetail.xml", false);
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
xmlhttp.send("");
xmlDoc = xmlhttp.responseXML;