//dname:xml路径
function loadXML(dname)
{
var xmlDoc;
if (window.ActiveXObject) {
xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
xmlDoc.async = false;
xmlDoc.load(dname);
} else if (document.implementation && document.implementation.createDocument) {
try{
xmlDoc = document.implementation.createDocument('', '', null);
xmlDoc.async = false;
xmlDoc.load(dname);
} catch(e){
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("GET",dname,false);
xmlhttp.send(null);
xmlDoc = xmlhttp.responseXML.documentElement;
}
} else {
return null;
}
return xmlDoc;
}
有些浏览器不允许加载本地的xml文件,所有要在项目中使用。正规格式的xml文件,是木问题的。have fun!~