Since your XML uses namespaces, there is no real good way to do this. For a direct xpath request, if it is safe to ignore the namespace, you can do something like this:
$ xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' pom.xml
If you want to do this in the “right” way, you need to run the shell to set the namespaces and output the desired value. Unfortunately, you will have to clear the exit prompts.
$ xmllint --shell pom.xml <<< 'setns ns=http://maven.apache.org/POM/4.0.0
cat /ns:project/ns:version/text()'
source
share