Issue
I'm having issue extracting the version number from POM. Can someone help me with it ?
POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>watcher</artifactId>
<version>0.0.1-SNAPSHOT</version>
<groupId>com.test.file</groupId>
<name>file-watcher</name>
<packaging>jar</packaging>
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<relativePath/>
<version>2.6.1</version>
</parent>
</project>
XPATH Expression:
//project/version/text()
Error: This is returning no match found
Solution
Your XPath here is correct, it should return 0.0.1-SNAPSHOT
It can be simulated on XPath simulators like this
So it's quite clear your problem is not with the XPath expression while with what you doing with it.
Answered By - Prophet
Answer Checked By - Marilyn (JavaFixing Volunteer)