更新时间:2023-12-05 21:44:46
将tag
的值改为2
和tag1
的3
的值,使用 XMLStarlet:
To change tag
's value to 2
and tag1
's value to 3
, using XMLStarlet:
xmlstarlet ed
-u '/root/tag' -v 2
-u '/root/tag1' -v 3
<old.xml >new.xml
使用您的示例输入:
Using your sample input:
xmlstarlet ed
-u '/root/tag' -v 2
-u '/root/tag1' -v 3
<<<'<root><tag>1</tag><tag1>2</tag1></root>'
...作为输出发出:
<?xml version="1.0"?>
<root>
<tag>2</tag>
<tag1>3</tag1>
</root>