js 读取XML

Posted (゚Д゚≡゚д゚)!? (°∀°)ノ欢迎光临Σ(゚д゚

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js 读取XML相关的知识,希望对你有一定的参考价值。

    function loadXMLDoc(file) {
        try //Internet Explorer
        {
            xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async=false;
            xmlDoc.load(file);
        }
        catch(e)
        {
            try //Firefox, Mozilla, Opera, etc.
            {
                xmlDoc=document.implementation.createDocument("","",null);
                xmlDoc.async=false;
                xmlDoc.load(file);
            }
            catch(e)
            {
                try //Google Chrome
                {
                    var xmlhttp = new window.XMLHttpRequest();
                    xmlhttp.open("GET",file,false);
                    xmlhttp.send(null);
                    xmlDoc = xmlhttp.responseXML.documentElement;
                }
                catch(e)
                {
                    error=e.message;
                }
            }
        }
        return xmlDoc;
    }

 

以上是关于js 读取XML的主要内容,如果未能解决你的问题,请参考以下文章