首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Augeas中动态迭代XML元素

如何在Augeas中动态迭代XML元素
EN

Stack Overflow用户
提问于 2015-11-11 11:02:59
回答 1查看 94关注 0票数 0

我想迭代XML中的所有子元素。

可以动态迭代吗?换句话说,我想在不知道最后一个元素号的情况下检查/编辑所有嵌套元素。

For eg:

在下面的"server-groups"元素中,包含三个服务器组子元素。我想在不知道计数的情况下迭代所有的服务器组元素。现在是三点。这样我才能访问最后一个元素。如果我不知道最后一个元素数,可以迭代吗?

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-11 11:33:11

在Augeas中,可以使用setm进行迭代。

代码语言:javascript
复制
  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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33649190

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档