Xpath and default namespaced xml
When using a default namespaced xml an xpath-expression need to look a bit different than when the xml uses namespace prefixes. Lets have a look at this namespaced XML:
The xpath used to get the title of the book would look like: /bk:bookstore/bk:book/bk:title
Now lets look at this default namespaced XML, it has no prefixes so we need to take another aproach to get the title of the book this time:
This time the xpath would look like: _/[local-name()=’bookstore’]/[local-name()=’book’]/*[local-name()=’title’] _The xpath matches any namespace and looks for the local name bookstore and after that book and title.
The following code shows how to use it, and the code including the xml files can be downloaded from github.