I have the following XML:
<bookstore>
<books>
<book name="book1" title="Title 1" author="Author 1"/>
<book name="book2" title="Title 2" author="Author 2"/>
<book name="book3" title="Title 1" author="Author 2"/>
</books>
<myBooks>
<book name="Test1" title="Title 1" author="Author 1"/>
<book name="Test2" title="Title 2" author="Author 1"/>
<book name="Test3" title="Title 1" author="Author 2"/>
</myBooks>
</bookstore>
I want to get all name
of book
in myBooks
that have not a corresponding book
in books
(title and author).
So, for the example, I want to retrieve: the book "Test2"
because the pair ("Title 2", "Author 1")
does not exist in books
.
So far, I have:
//myBooks/book[not(@title = //books/book/@title and @author = //books/book/@author)]
But, of course, in that case, the above XPath does not work because the combination ("Title 2", "Author 1") exists (from "book2" and "book1").
How can I apply the and
operator on the same node?