如何更改属性值以及XML中位置的变化?
我有以下问题: 我的XML(简化): 但问题是:用户名条目并不总是在位置1上。在augeas有没有办法找到“匹配”或某种正则表达式的位置如何更改属性值以及XML中位置的变化?,xml,puppet,augeas,Xml,Puppet,Augeas,我有以下问题: 我的XML(简化): 但问题是:用户名条目并不总是在位置1上。在augeas有没有办法找到“匹配”或某种正则表达式的位置 augtool> match /files/test.xml/configuration/properties/*/#attribute/name username 工作很好,结果很好 /files/test.xml/configuration/properties/property[1]/#attribute/name 但是我不知道在设置值时如何
augtool> match /files/test.xml/configuration/properties/*/#attribute/name username
工作很好,结果很好
/files/test.xml/configuration/properties/property[1]/#attribute/name
但是我不知道在设置值时如何使用这些信息。您需要做的是:
set /files/test.xml/configuration/properties/property[#attribute/name='username']/#text NEWUSER
这将选择其
#属性/名称
子节点与用户名
匹配的属性(/files/test.xml/configuration/properties/property
),并将其#文本
子节点设置为新用户
。非常感谢。如果不存在具有上述属性的XML元素,如何选中“插入新的XML元素”,如果存在则如何使用上述属性修改XML元素?默认情况下,augeas只能在/etc/和/boot中查看文件,您是否创建了自定义镜头?
/files/test.xml/configuration/properties/property[1]/#attribute/name
set /files/test.xml/configuration/properties/property[#attribute/name='username']/#text NEWUSER