根据属性名xmlstarlet更新标签值
Update tag value according to attribute name xmlstarlet
我有一个文件:
<?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
但我无法更改 <font place="ActiveWindow">
下的 <name>
和 <size>
的值。我已经试过了,但是没有用:
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
有什么帮助吗?
引用你的路径以防止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
我有一个文件:
<?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
但我无法更改 <font place="ActiveWindow">
下的 <name>
和 <size>
的值。我已经试过了,但是没有用:
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
有什么帮助吗?
引用你的路径以防止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