491339 messages in 933 lists

A hack is to extend org.jaxen.dom.DocumentNavigator and override:

a)  getNamespacePrefix and getNamespaceStringValue to return "" and null.
b) translateNamespacePrefixToUri to return null (if you want to disable
namespaces in the XPath expression as well).

Of course, the 'cleaner' way is to use the local-name(), e.g.

/*[local-name()='bar' and @name='something']


ptomsic wrote:
> is it possible to have the DOMXPath disregard namespaces, such that if i were
> to have an XML that contained
>
> <foo:bar name="something"/>
>     <foo:baz>
>         <foo:zing>targetValue</foo:zing>
>     </foo:baz>
> </foo:bar>
>
> is there a way for me to do the following:
>
> XPath path = new DOMXPath("/bar[@name='something']/baz/zing/text()");
> path.selectSingleNode(domDoc);
>
> to obtain "targetValue"  
>
> ?
>
> thanks
>
>   

Message Thread
[jaxen-user] disable namespaces? ptomsic (ptomsic@gmail...)
15 Nov 2007
Re: [jaxen-user] disable namespaces? Nikhil Dinesh (nikhild@seas.upenn...)
15 Nov 2007
Copyright 2006-2008 The Codehaus Foundation
Powered by Codehaus March (Version: 0.1-HEAD)