Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Having issue while extracting version number from pom using xPath

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

//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
This is what I see there
So it’s quite clear your problem is not with the XPath expression while with what you doing with it.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading