Beware of the context in XPATH

I work a lot with XPATH (but i am not an expert yet), during my work i came across a very non intuitive situation for, the thing i wanted to do is to return the first item out of all the children in the document so i used [1] and apparently i got more than one results.

Consider the following XML:


Lets say i want to get the first Book on the entire document, i used the following XPATH and it gave me the following output (2 items)


Apparently i needed to take in mind the context that Book can be found under and do the followingMezer_01-18_06-32-39

So although i understand the solution, this was not the intuitive one,….  (watch it)

Beware of the context in XPATH Beware of the context in XPATH Reviewed by Ran Davidovitz on 8:34 PM Rating: 5

No comments:

Powered by Blogger.