一个XML文件下有多个<type>节点,我想找出所有的type节点,XPath语句怎么写啊

解决方案 »

  1.   

    XmlDocument xml=new XmlDocument();
    xml.SelectSingleNode("type");
      

  2.   


    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load("data.xml");
    XmlNodeList nodeList = xmlDoc.SelectNodes("//type");
      

  3.   

    忘了说了,要查找type节点的内容是"CD"的
      

  4.   

    还要问一下XPath 定位的问题XmlDocument doc = new XmlDocument();
    doc.Load(.xml);
    XmlNode root = doc.DocumentElement//这里能不能用XPath语句定位到文档的任意节点
      

  5.   

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load("data.xml");
    XmlNodeList nodeList = xmlDoc.SelectNodes("//type[text()='CD']");
    可以定位到任意节点,上面就是一个例子.
    这里有些挺不错的文章,建议你自己看看.
    http://www.netvtm.com/w3s/xpath/index.asp