[英]How to dynamically iterate XML Element in Augeas
我想迭代XML中的所有子元素。
是否可以動態迭代? 換句話說,我想在不知道最后一個元素編號的情況下檢查/編輯所有嵌套元素。
例如:
在下面的“服務器組”元素中包含三個服務器組子元素。 我想在不知道計數的情況下迭代所有服務器組元素。 現在是三個。 這樣我就可以訪問最后一個元素。 如果我不知道最后一個元素號,是否可以迭代?
<server-groups>
<server-group name="ServiceGroupOne" profile="full-ha">
<system-properties>
<property name="jboss.default.multicast.address" value="232.0.2.20" boot-time="true"/>
<property name="modcluster.proxylist" value="192.168.79.77:7777" boot-time="true"/>
<property name="modcluster.lbgroup" value="SearchGroupOne" boot-time="true"/>
</system-properties>
</server-group>
<server-group name="ServiceGroupTwo" profile="full-ha">
<system-properties>
<property name="jboss.default.multicast.address" value="232.0.2.20" boot-time="true"/>
<property name="modcluster.lbgroup" value="SearchGroupTwo" boot-time="true"/>
<property name="modcluster.proxylist" value="192.168.79.77:7777" boot-time="true"/>
</system-properties>
</server-group>
<server-group name="ServiceGroupThree" profile="full-ha">
<system-properties>
<property name="modcluster.lbgroup" value="CommonSearchGroup" boot-time="true"/>
<property name="modcluster.proxylist" value="192.168.79.77:7777" boot-time="true"/>
<property name="jboss.default.multicast.address" value="232.0.2.20" boot-time="true"/>
</system-properties>
</server-group>
</server-groups>
在Augeas中,可以使用setm
進行迭代:
COMMAND
setm - set the value of multiple nodes
SYNOPSIS
setm <BASE> <SUB> [<VALUE>]
DESCRIPTION
Set multiple nodes in one operation. Find or create a node matching SUB
by interpreting SUB as a path expression relative to each node matching
BASE. If SUB is '.', the nodes matching BASE will be modified.
OPTIONS
<BASE> the base node
<SUB> the subtree relative to the base
<VALUE> the value for the nodes
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.