Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何更改属性值以及XML中位置的变化?_Xml_Puppet_Augeas - Fatal编程技术网

如何更改属性值以及XML中位置的变化?

如何更改属性值以及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 但是我不知道在设置值时如何

我有以下问题:

我的XML(简化):

但问题是:用户名条目并不总是在位置1上。在augeas有没有办法找到“匹配”或某种正则表达式的位置

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