xmlstarlet 追加并插入新行值

2023-12-11

我想知道如何使用 xmlstarlet 添加新行。

我的目标是添加一个<audio>track_01</audio> after 作业/输入/file_input/uri。

<?xml version="1.0" encoding="UTF-8"?>
<job version="2.10.8">
  <input>
    <deblock_enable>Auto</deblock_enable>
    <deblock_strength>0</deblock_strength>
    <no_psi>false</no_psi>
    <order>1</order>
    <timecode_source>zerobased</timecode_source>
    <file_input>
      <certificate_file nil="true"/>
      <password>upass</password>
      <uri>source_path</uri>
      <username>uname</username>
    </file_input>
    <file_group_settings>
      <rollover_interval nil="true"/>
      <destination>
        <password>upass</password>
        <username>uname</username>
        <uri>destination_path</uri>
      </destination>
    </file_group_settings>
  </input>
</job>

如何使用以下代码插入新行?

xmlstarlet edit \
           --update "//job/input/file_input/uri" \
           --value 's3://my_source' \
           --update "//job/input/file_group_settings/destination/uri" \
           --value 's3://mydestination' file.xml

非常感谢


我建议附加(--append)在所需的节点/元素之后是一个新元素(--type elem),名称为音频(--name "audio")和值(--value "track_01"):

xmlstarlet edit \
           --update "//job/input/file_input/uri" \
           --value 's3://my_source' \
           --update "//job/input/file_group_settings/destination/uri" \
           --value 's3://mydestination' \
           --append "//job/input/file_input/uri" \
           --type elem --name "audio" --value "track_01" file.xml

如果您想就地编辑 file.xml,请添加选项-L.


See: xmlstarlet edit --help

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

xmlstarlet 追加并插入新行值 的相关文章

随机推荐