I want to read a pom.xml ('Project Object Model' of Maven) and extract the version information. Here is an example:
<?xml version="1.0" encoding="UTF-8"?><project
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>project-parent</artifactId>
<name>project-parent</name>
<version>1.0.74-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.sybase.jconnect</groupId>
<artifactId>jconnect</artifactId>
<version>6.05-26023</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
How can I extract the version '1.0.74-SNAPSHOT' from above?
Would love to be able to do so using simple bash scripting sed or awk. Otherwise a simple python is preferred.
EDIT
Constraint
The linux box is in a corporate environment so I can only use tools that are already installed (not that I cannot request utility such as xml2, but I have to go through a lot of red-tape). Some of the solutions are very good (learn a few new tricks already), but they may not be applicable due to the restricted environment
updated xml listing
I added the dependencies tag to the original listing. This will show some hacky solution may not work in this case
Distro
The distro I am using is RHEL4