zoukankan      html  css  js  c++  java
  • JavaScript XML相关

    1. function convert_string_to_xml(strXML)   
    2. {   
    3.     if (window.ActiveXObject) {   
    4.         xmlDoc=new ActiveXObject("Microsoft.XMLDOM");   
    5.         xmlDoc.async="false";   
    6.         xmlDoc.loadXML(strXML);   
    7.         return xmlDoc;   
    8.     } else {   
    9.         parser=new DOMParser();   
    10.         xmlDoc=parser.parseFromString(strXML,"text/xml");   
    11.         return xmlDoc;   
    12.     }   

     

    1. function convert_xml_to_string(xmlObject)   
    2. {   
    3.     if (window.ActiveXObject) { // for IE   
    4.         return xmlObject.xml;   
    5.     } else {   
    6.         return (new XMLSerializer()).serializeToString(xmlObject);   
    7.     }   
    8. }  

     

    1. IE
    2. <script type="text/javascript">
    3.     function load_xml_content_string(xmlData) {
    4.         if (window.ActiveXObject) {
    5.             //for IE
    6.             xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    7.             xmlDoc.async="false";
    8.             xmlDoc.loadXML(xmlData);
    9.             return xmlDoc;
    10.         } else if (document.implementation && document.implementation.createDocument) {
    11.             //for Mozila
    12.             parser=new DOMParser();
    13.             xmlDoc=parser.parseFromString(xmlData,"text/xml");
    14.             return xmlDoc;
    15.         }
    16.     }
    17.     var xmlObject = load_xml_content_string("<employee><age>12</age></employee>");
    18.    
    19.     var xmlString = xmlObject.xml;
    20.     alert(string);
    21. </script>

       

    22. FF
    23. <script type="text/javascript">
    24.     function load_xml_content_string(xmlData) {
    25.         if (window.ActiveXObject) {
    26.             //for IE
    27.             xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    28.             xmlDoc.async="false";
    29.             xmlDoc.loadXML(xmlData);
    30.             return xmlDoc;
    31.         } else if (document.implementation && document.implementation.createDocument) {
    32.             //for Mozila
    33.             parser=new DOMParser();
    34.             xmlDoc=parser.parseFromString(xmlData,"text/xml");
    35.             return xmlDoc;
    36.         }
    37.     }
    38.     var xmlObject = load_xml_content_string("<employee><age>12</age></employee>");
    39.    
    40.     var xmlString = (new XMLSerializer()).serializeToString(xmlObject);
    41.     alert(xmlString);
    42. </script>
     
     
    作者:易简.道    
     
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    scala IDE for Eclipse开发Spark程序
    RedHat6.5安装Spark单机
    RedHat6.5安装Spark集群
    Spark任务提交jar包依赖解决方案
    本地开发spark代码上传spark集群服务并运行
    Maven3.5.0安装与配置+Eclipse应用
    MAVEN Scope使用
    Maven下载项目依赖jar包和使用方法
    maven中把依赖的JAR包一起打包
    Maven+Eclipse+SparkStreaming+Kafka整合
  • 原文地址:https://www.cnblogs.com/xyicheng/p/1675029.html
Copyright © 2011-2022 走看看