6

at the moment I am struggeling editing a XML file. When I write the command

xml ed -u "/project/version" -v "2.7.13-NEW-SNAPSHOT" pom.xml > ./pom_new.xml

it writes the new xml file, but when I open the file nothings changed in it.

Heres a part of the given xml, i want to edit:

<?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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.groupID.test</groupId>
    <artifactId>test-api-parent-pom</artifactId>
    <version>2.7.13-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>test-api-parent-pom</name>
    ...
    ...
</project>

Any ideas on that?

kjhughes
  • 106,133
  • 27
  • 181
  • 240

1 Answers1

11

Your xmlstarlet command will work if you take account of your document's namespace using -N p=http://maven.apache.org/POM/4.0.0:

xml ed -N p=http://maven.apache.org/POM/4.0.0 -u "/p:project/p:version" -v "2.7.13-NEW-SNAPSHOT" pom.xml > ./pom_new.xml

Reference links

kjhughes
  • 106,133
  • 27
  • 181
  • 240