zoukankan      html  css  js  c++  java
  • a crossbroswer solution for parse xml fragment

     1 function parseXml(xml) {
     2         var xmldom = null;
     3 
     4         if (typeof DOMParser != "undefined") {
     5             xmldom = (new DOMParser()).parseFromString(xml, "text/xml");
     6             var errors = xmldom.getElementByTagName("parsererror");
     7             if (errors.length) {
     8                 throw new Error("XML parsing error:" + errors[0].textContent);
     9             }
    10         } else if (document.implementation.hasFeature("LS", "3.0")) {
    11             var implementation = document.implementation;
    12             var parser = implementation.createLSParser(implementation.MODE_SYNCHRONOUS, null);
    13             var input = implementation.createLSInput();
    14             input.stringDate = xml;
    15             xmldom = parser.parse(input);
    16         } else if (typeof ActiveXObject != "undefined") {
    17             xmldom = createDocument();
    18             xmldom = loadXML(xml);
    19             if (xmldom.parseError != 0) {
    20                 throw new Error("XML parsing error:" + xmldom.parseError.reason);
    21             }
    22         } else {
    23         throw new Error("NO XML parser available.");
    24     }
    25     return xmldom;
    26     }
  • 相关阅读:
    二项式反演
    快速沃尔什变换
    springMVC的form标签
    springMVC的拦截器配置
    RESTful使用方法
    springMVC数据绑定
    使用spring框架自带的字符拦截器
    将idea中的项目上传至github
    springMVC的使用方式
    springMVC的概述
  • 原文地址:https://www.cnblogs.com/ongoing/p/3084786.html
Copyright © 2011-2022 走看看