I have a bunch of nodes like this:
<root>
<books>
<book id="1">Book 1</book>
<book id="2">Book 2</book>
<book id="3">Book 3</book>
</books>
</root>
What I want is to get the id of the book with text node "Book 2". How do I do this? I tried this without any result ($doc is my document path):
let $b := $doc/root/books/book[book = "Book 2"]
return data($b/@id)
EDIT: I meant that $doc is the document node, not only the path.