Reputation: 14861
I have an XML which looks something like this:
<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>
What is the XPath to select all the "Book" nodes whose parent "Author" node has the value "JK Rowling"?
Upvotes: 1
Views: 705
Reputation: 17782
This is properly more most intuitive and strict which selects all the books which have a Author
which Name
attribute is 'JK Rowling'
as a parent. And the Author
must also have the Library
as a parent.
/Library/Author[@Name='JK Rowling']/Book
Upvotes: 3