当前位置 : 主页 > 网络编程 > JavaScript >

解析xml.txt

来源:互联网 收集:自由互联 发布时间:2021-07-03
解析xml.txt function parseXML(text){ var xmlDoc = null; try //Internet Explorer { xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = "false"; xmlDoc.loadXML(text); } catch (e) { try //Firefox, Mozilla, Opera, etc. { parser = n
解析xml.txt
function parseXML(text){
    var xmlDoc = null;
    try //Internet Explorer
    {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = "false";
        xmlDoc.loadXML(text);
    } 
    catch (e) {
        try //Firefox, Mozilla, Opera, etc.
        {
            parser = new DOMParser();
            xmlDoc = parser.parseFromString(text, "text/xml");
        } 
        catch (e) {
            alert(e.message);
            return;
        }
    }
    return xmlDoc;
}
//该片段来自于http://www.codesnippet.cn/detail/1509201513688.html
网友评论