How can I get JDOM/XPath to ignore namespaces?

AdSR picture AdSR · Apr 9, 2010 · Viewed 10.8k times · Source

I need to process an XML DOM, preferably with JDOM, where I can do XPath search on nodes. I know the node names or paths, but I want to ignore namespaces completely because sometimes the document comes with namespaces, sometimes without, and I can't rely on specific values. Is that possible? How?

Answer

Tomalak picture Tomalak · Apr 9, 2010
/ns:foo/ns:bar/@baz

becomes

/*[local-name() = 'foo']/*[local-name() = 'bar']/@baz

You get the point. Don't expect that to be lightning-fast either.