Skellywag

Friday, July 22, 2005

What's in a name(space)? Too much...

I finally had to admit knowing practially nothing about XML namespaces, particularly the default namespace, having fought for 4 solid hours over an (apparently) simple bit of XML.

Basically, using the default namespace screwsup XPath queries. A simple query like book/title against this XML gives no results:

<books xmlns="some-namespace">
  <book>
    <title>The Meaning of Liff</title>
  </book>
</books>

The solution is use a blank default namespace:

<books xmlns="">
  <book>
    <title>The Meaning of Liff</title>
  </book>
</books>
The book/title query now returns data, as expected.

References:


0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home