xpath查询过滤器属性

时间:2015-12-15 10:15:10

标签: xml xpath

尝试过滤id = bk112的图书失败。  我正在使用cygwin最新和最好的。  让任何人得到这个工作吗?

file:/tmp/myLOG/xpath-filter/book.xml

01 xpath show all the 02 books in XML file
------------------------------------------
$  xpath /tmp/myLOG/xpath-filter/book.xml catalog/book
Found 2 nodes:
-- NODE --
<book id="bk111">
      <author>O'Brien, Tim</author>
      <title>MSXML3: A Comprehensive Guide</title>
      <genre>Computer</genre>
      <price>36.95</price>
      <publish_date>2000-12-01</publish_date>
      <description>The Microsoft MSXML3 parser is covered in
      detail, with attention to XML DOM interfaces, XSLT processing,
      SAX and more.</description>
</book>
-- NODE --
<book id="bk112">
      <author>Galos, Mike</author>
      <title>Visual Studio 7: A Comprehensive Guide</title>
      <genre>Computer</genre>
      <price>49.95</price>
      <publish_date>2001-04-16</publish_date>
      <description>Microsoft Visual Studio 7 is explored in depth,
      looking at how Visual Basic, Visual C++, C#, and ASP+ are
      integrated into a comprehensive development
      environment.</description>
   </book>

02 xpath属性id =“bk112”,找不到任何内容

$  xpath /tmp/myLOG/xpath-filter/book.xml catalog/book[@id="bk112"]
No nodes found

1 个答案:

答案 0 :(得分:0)

也许这样吗?

catalog/book[contains(., "bk112")]