use*_*256 4 xml xpath element edit xmlstarlet
目前我正在编辑XML文件.当我写命令
xml ed -u "/project/version" -v "2.7.13-NEW-SNAPSHOT" pom.xml > ./pom_new.xml
Run Code Online (Sandbox Code Playgroud)
它写了新的xml文件,但是当我打开文件时,nothings在其中发生了变化.
下面是给定xml的一部分,我想编辑:
<?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>
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
如果您使用以下方法考虑文档的命名空间,则xmlstarlet命令将起作用-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
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
529 次 |
最近记录: |