## Sunday, January 17, 2010

### 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 following

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