Reputation: 1
Here is how my xml file looks like:
<modelVersion>4.0.0</modelVersion>
<version>5.1.3-SNAPSHOT</version>
<parent>
<artifactId>xxx</artifactId>
<groupId>group</groupId>
<version>5.1.3-SNAPSHOT</version>
</parent>
<artifactId>yyy</artifactId>
<packaging>pom</packaging>
<name>artifact name</name>
<modules>
<module>m1</module>
<module>m2</module>
<module>m3</module>
</modules>
I want to delete the "-SNAPSHOT" string ONLY from the tag within <parent>.
How do I do that?
Upvotes: 0
Views: 133
Reputation: 36059
This is past the capabilities of simple line-based approaches. You might use sed magic with line selection operators or do perl.
An example in sed would be (but just for educational purposes! Don't try this at home! This script is pretty unstable towards changes in the XML):
/<parent>/,/<.parent>/s/-SNAPSHOT//
However, XSLT and xsltproc
is definitely the preferred solution for such heavy XML-processing duties.
Upvotes: 1