Re: [xml] Default namespaces with XPath



Can't you go:

/*[local-name()='presence']/*[local-name()='tuple']

or even:

/*[local-name()='presence'][namespace-uri()='urn:ietf:params:xml:ns:cpim-pidf']/*[local-name()='tuple'][namespace-uri()='urn:ietf:params:xml:ns:cpim-pidf']

?

ste


Daniel Veillard wrote:
On Wed, Dec 25, 2002 at 01:42:40PM +0530, Ganesh Sivaraman wrote:

Hi,
  I'm still learning the ropes with XML. I understand I can use XPath to access particular nodes in the DOM 
tree.
I have a xml doc. with default namespaces as below:

[...]

What am I doing wrong and how do I use XPath with default namespaces?


  You cannot, it's a restriction of the XPath specification !
You have to define a prefix for the namespace, register it with
xmlXPathRegisterNs() and use that prefix in the XPath expression.
There is no way around this, this is defined in the XPath spec
  http://www.w3.org/TR/xpath#node-tests


Daniel





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]