zoukankan      html  css  js  c++  java
  • js读取xml文件

    xml文件: 

    <?xml version="1.0" encoding="utf-8" ?>
    <root>
      
    <main id="id1">
        
    <id="f1"><name>jifew1</name></n>
        
    <id="f2"><name id="idv">jifew2</name></n>
      
    </main>
    </root>

    js:

       window.onload=function(){
           
        
    var xml=new ActiveXObject("MSXML2.DOMDocument.5.0"); //创建对象
        xml.async=false; //同步
        xml.load(
    "x.xml");  //载入
        alert(xml.documentElement.selectNodes(
    "main/n/name")[1].tagName); //取标签名
        alert(xml.documentElement.selectNodes("main/n/name")[1].text);   //取值
        alert(xml.documentElement.selectNodes("main/n/name")[1].getAttribute("id")); //取属性
    }

  • 相关阅读:
    IEnumerator & IEnumerable
    GameObject.Active
    Unity3D的四种坐标系
    gvim
    Platform Dependent Compilation
    delegate
    new 约束
    UIPanel
    UIButton
    UISprite
  • 原文地址:https://www.cnblogs.com/winner/p/1344341.html
Copyright © 2011-2022 走看看