JS - 读取XML文件

 1 function loadXmlFile( xmlFile ){
 2     var xmlDom = null;
 3     if (window.ActiveXObject){
 4         xmlDom = new ActiveXObject("Microsoft.XMLDOM");
 5         //xmlDom.loadXML(xmlFile);//如果用的是XML字符串
 6         xmlDom.load(xmlFile);//如果用的是xml文件。
 7     }else if (document.implementation && document.implementation.createDocument){
 8                 var xmlhttp = new window.XMLHttpRequest();
 9                 xmlhttp.open("GET", xmlFile, false);
10                 xmlhttp.send(null);
11                 xmlDom = xmlhttp.responseXML;
12            } else {
13                 xmlDom = null;
14            }
15     return xmlDom;
16 }
兼容IE,FF,Chrome
posted on 2009-10-12 13:33  L.Rain  阅读(278)  评论(0编辑  收藏  举报