I'm using a library method for xpath evaluation (apache commons-text
's XmlStringLookup
) that sets the DocumentBuilderFactory
's namespace awareness to true
and I can't change that.
I need to query a pom.xml
file with this, that has a default namespace with no prefix:
<project xmlns="http://maven.apache.org/POM/4.0.0" ...>
<modelVersion>4.0.0</modelVersion>
...
I would want to be able to query just like:
/project/modelVersion
but because of the namespace awareness, the results come out empty. I know I can use something like :
//*[local-name()="project"] ...
but that's just cumbersome. The question is: is there any Xpath syntax to query namespaces without prefix? Something like:
/:project/:modelVersion