0

XML のすべての子要素を繰り返し処理したいと考えています。

動的に反復することは可能ですか? つまり、最後の要素番号を知らずに、ネストされたすべての要素をチェック/編集したいのです。

例:

次の「server-groups」要素には、3 つのserver-group子要素が含まれています。カウントを知らずにすべての server-group 要素を反復したいと思います。今のところ 3つです。最後の要素にアクセスできるように。最後の要素番号がわからない場合、反復することはできますか?

<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>
4

1 に答える 1

1

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
于 2015-11-11T11:33:11.387 に答える