读取XML的函数:
var loadXMLFailed=false;
function loadXML(xmlFile){
var _xmlDoc=null;
var failed=false;
if (window.ActiveXObject){
_xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}else{
try{
_xmlDoc=document.implementation.createDocument("","",null);
if (_xmlDoc.documentElement==null || typeof(_xmlDoc.documentElement)=='undefined') throw new Error();
}catch(ex){
var xmlhttp=new window.XMLHttpRequest();
xmlhttp.open("GET",xmlFile,false);
xmlhttp.send(null);
_xmlDoc=xmlhttp.responseXML;
failed=true;
}
}
if ((!failed)&&_xmlDoc!=null){
_xmlDoc.async=false;
try{
_xmlDoc.load(xmlFile);
}catch(ex){
_xmlDoc=null;
if (!loadXMLFailed){
alert('您的浏览器不支持XML,本站部分功能将可能无法使用,建议您更换浏览器!');
loadXMLFailed=true;
}
}
}
return _xmlDoc;
}