我有一个看起来像这样的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>
选择父“作者”节点的值为“JK罗琳”的所有“预订”节点的XPath是什么?
答案 0 :(得分:3)
这是最直观和严格的选择,它选择所有Author
Name
属性为'JK Rowling'
作为父级的书籍。 Author
还必须将Library
作为父级。
/Library/Author[@Name='JK Rowling']/Book