【问题标题】:xmlstarlet replace xml node valuexmlstarlet 替换 xml 节点值
【发布时间】:2018-03-05 13:13:00
【问题描述】:

我是使用 xmlstarlet 的新手。我想知道如何使用 xmlstarlet 更改 xml 节点的值。

我尝试了一些东西。 xmlstarlet ed --inplace -u '/file_input/uri' 'string("s3://my_source")' template.xml > output.xml

没用。

我的预期输出为 s3://my_sources3://mydestination。我想更改 source_pathdestination_path 节点。

<?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


    【解决方案1】:

    使用 xmlstarlet:

    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
    

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


    见:xmlstarlet edit --help

    【讨论】:

    猜你喜欢
    • 2014-08-27
    • 2013-07-11
    • 2013-09-07
    • 1970-01-01
    • 2019-01-09
    • 1970-01-01
    • 2015-10-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多