<?xml version="1.0" encoding="UTF-8"?>
<Order>
  <zw1 ks="0">
    <xm1 zt="0">XM111</xm1>
    <xm2 zt="1">XMS22</xm2>
    <xm3 zt="2">XM333</xm3>
    <xm4 zt="3">XM555</xm4>
  </zw1>
</Order>

解决方案 »

  1.   

    首先你要声名一个变量来hold这个xml,然后其它的操作和DOM差不多。
    给你一个例子里看看。http://www.phpx.com/viewarticle.php?id=136521
    还有一个比较流行的技术就是xpath。这是教程, 估计半小时就可以看完。 http://www.w3school.com.cn/xpath/xpath_intro.asp
      

  2.   


    这个应该能帮上你:
    http://www.w3school.com.cn/example/xdom_examples.asp
      

  3.   

    好好看看DOM!看你要怎么读了,如果从头到尾就从documentElement开始遍历它的childNodes(A),再嵌套读A的childNodes,以此进行...
    如果过滤节点或读指定节点用selectSingleNode(xpath表达式);到微软下一个MSXML parser,装完有很全的文档chm
    url:http://www.microsoft.com/downloads/details.aspx?FamilyID=2cf40ae6-368c-4b6b-a185-2dfa92fb7993&DisplayLang=en
      

  4.   

    function parseXML()
    {
    try //Internet Explorer
      {
      xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
      }
    catch(e)
      {
      try //Firefox, Mozilla, Opera, etc.
        {
        xmlDoc=document.implementation.createDocument("","",null);
        }
      catch(e)
        {
        alert(e.message);
        return;
        }
      }
    xmlDoc.async=false;
    xmlDoc.load("/example/xmle/note.xml");
    document.getElementById("to").innerHTML=xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
    document.getElementById("from").innerHTML=xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
    document.getElementById("message").innerHTML=xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
    }
    </script>
      

  5.   

    Index.html文件:
    <script language="javascript">
    var xmlDoc;
    function initialize()
    {
      if(window.ActiveXObject)
        {
          xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
          xmlDoc.onreadystatechange=function()
          {
            if(xmlDoc.readyState==4)
            {
              handleXmlDoc();
            }
          }
          xmlDoc.load("data.xml");
        }
      else if(document.implementation&&document.implementation.createDocument)
      {
        xmlDoc=document.implementation.createDocument('','',null);
        xmlDoc.onload=handleXmlDoc;
        xmlDoc.load("data.xml");
      }
    }
    function handleXmlDoc()
    {
      var root=xmlDoc.documentElement;
      var info=root.getElementsByTagName("info")[0];
      alert(info.getAttribute("type"));
      for(var i=0; i<info.childNodes.length; i++)
      {
        alert(info.childNodes[i].firstChild.nodeValue);
      }
    }
    window.onload=initialize;
    </script>xml文件:
    <?xml version="1.0" encoding="GB2312"?>
    <root>
        <info type="student">
          <name>Hello</name>
          <sex>Female</sex>
        </info>
    </root>