//加载xml文件对象
function loadXMLDoc(dname){
try {
xmlhttp=new XMLHttpRequest();
} catch (e) {
try {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert(e.message)
}
}
try {
xmlhttp.open("GET",dname,false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
return (xmlDoc);
}catch(e) {alert(e.message)}
return(null);
}
//取指定结点对象下指定结点内的文本
function getNodeText(nodeObj,keyName){
if(nodeObj.getElementsByTagName(keyName).length>0
&&nodeObj.getElementsByTagName(keyName)[0].childNodes.length>0){
return nodeObj.getElementsByTagName(keyName)[0].childNodes[0].nodeValue;
}
return "";
}
以上函数兼容IE6,7,8,9,firefox, chrome, opera,safari(win)浏览器