I would like to iterate all the child elements in the XML.
Is it possible to iterate dynamically ? In other words, I would like to check / edit all the nested elements without knowing the last element number.
For eg:
In the following "server-groups" element contains three server-group child element. I would like to iterate all the server-group element without knowing the counts. Right now It is three. So that I could access the last element. If I dont know the last element number, Is it possible to iterate ?
<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>
In Augeas, iterating can be done using 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