根据属性名称xmlstarlet更新标签值

问题描述 投票:0回答:1

我有一个文件:

<?xml version="1.0"?>
<openbox_config xmlns="http://openbox.org/3.4/rc" xmlns:xi="http://www.w3.org/2001/XInclude">
  <theme>
    <name>YYYY</name>
    <titleLayout>XXXX</titleLayout>
    <font place="ActiveWindow">
      <name>ZZZZ</name>
      <size>8</size>
    </font>
  </theme>
</openbox_config>

我可以使用此命令更改<name><titleLayout>的值:

xmlstarlet ed -L -N a="http://openbox.org/3.4/rc" -u /a:openbox_config/a:theme/a:name -v YYYY test.xml

xmlstarlet ed -L -N a="http://openbox.org/3.4/rc" -u /a:openbox_config/a:theme/a:titleLayout -v XXXX test.xml

但是我无法在<name>下更改<size><font place="ActiveWindow">的值。我已经尝试过了,但是没有用:

xmlstarlet ed -L -N a="http://openbox.org/3.4/rc" -u /a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:name -v AAAA test.xml

有帮助吗?

xml bash xml-namespaces xmlstarlet openbox
1个回答
1
投票

引用您的路径以防止bash解释内容:

xmlstarlet ed -L -N a="http://openbox.org/3.4/rc" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:name' -v AAAA test.xml
© www.soinside.com 2019 - 2024. All rights reserved.