zoukankan      html  css  js  c++  java
  • 动态创建XML文档

     
           var createXML = function (str) {
              if (typeof DOMParser !== "undefined") {
                return (new DOMParser()).parseFromString(str, "application/xml");
              }else if (typeof ActiveXObject != "undefined") {
                if (typeof arguments.callee.activeXString !== "string"){//在createXML上设置一个静态成员
                  var versions = ["MSXML2.DOMDocument.6.0",
                    "MSXML2.DOMDocument.5.0",
                    "MSXML2.DOMDocument.4.0",
                    "MSXML2.DOMDocument.3.0",
                    "MSXML2.DOMDocument",
                    "Microsoft.XMLDOM"];
                  for (var i=0,len=versions.length; i < len; i++){
                    try {
                      var xml = new ActiveXObject(versions[i]);
                      arguments.callee.activeXString = versions[i];
                      xml = null;
                    } catch (e){}
                  }
                }
                xml = new ActiveXObject(arguments.callee.activeXString);
                xml.async="false";
                xml.loadXML(str);
                return xml
              }
            }
    
            var xml = createXML('<xml id="xx"><book><title>司徒正美</title></book></xml>');
    
  • 相关阅读:
    线程状态
    线程的两种实现方式
    设计模式
    移动端适配总结(补充一个移动端touch案例)
    echart.js组件编写
    vuex,文件夹整理
    rem初始化
    PC初始化
    移动端初始化
    三角形实现原理
  • 原文地址:https://www.cnblogs.com/rubylouvre/p/1631443.html
Copyright © 2011-2022 走看看