<bookstore><book category="children">
  <title lang="en">Harry Potter</title> 
  <author>J K. Rowling</author> 
  <year>2005</year> 
  <price>29.99</price> 
</book><book category="cooking">
  <title lang="en">Everyday Italian</title> 
  <author>Giada De Laurentiis</author> 
  <year>2005</year> 
  <price>30.00</price> 
</book>
</bookstore>比如这样,我想查找作者是J K. Rowling的所有<book>节点,请问用什么方法呢?是不是一定要遍历
谢谢

解决方案 »

  1.   

    晕,没方法了?
    getElementsByTagName是不是只能找到元素节点,不能找文本节点?
      

  2.   

    没那么复杂,用MSXML的XPATH
    下面这条语句就能达到你的要求。
    (//book)[author='J K. Rowling ']
      

  3.   

    得到text的值“J K. Rowling”。然后搜索查找。对于一棵树来说,不遍历下来,无法实现。
      

  4.   

    支持 XPath表达式最好 其他方法都相对麻烦 
      

  5.   

    XML不是结构化的,不能像SQL一样进行查询,每次找信息都只能遍历吧