我有一个看起来像这样的XML:
<Library>
<Author Name = "JRR Tolkien">
<Book Title = "Lord Of the Rings" />
<Book Title = "The Hobbit" />
</Author>
<Author Name = "JK Rowling">
<Book Title = "Harry Potter and the Sorcerers Stone" />
<Book Title = "Harry Potter and the Prisoner of Azkaban" />
</Author>
</Library>
XPath是什么,用于选择其父“ Author”节点的值为“ JK Rowling”的所有“ Book”节点?
请您参考如下方法:
这是最直观,最严格的选择,它将所有具有Author
(Name
属性为'JK Rowling'
的书)作为父书的书。并且Author
还必须具有Library
作为父级。
/Library/Author[@Name='JK Rowling']/Book