首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在同一个xml文件中存储一个值并重用它?

如何在同一个xml文件中存储一个值并重用它?
EN

Stack Overflow用户
提问于 2015-07-15 09:14:21
回答 1查看 36关注 0票数 0

我有一个autoinst.xml,它将在系统安装过程中使用,用于安装arp连接,它被配置为接收用户有关ip、网关和网络掩码的输入,如下所示

代码语言:javascript
复制
        <path>networking,dns,hostname</path>
        <title>INS Server Network Settings</title>
        <question>Enter Hostname</question>
        <stage>cont</stage>
        <default></default>
    </ask>

    <ask>
        <dialog config:type="integer">2</dialog>
        <element config:type="integer">2</element>
        <path>networking,interfaces,0,ipaddr</path>
        <title>INS Server Network Settings</title>
        <question>Enter the server IP address:</question>
        <stage>cont</stage>
        <default>1.2.3.4</default>
    </ask>

    <ask>
    <dialog config:type="integer">2</dialog>
        <element config:type="integer">3</element>
        <path>networking,interfaces,0,netmask</path>
        <question>Enter the server netmask:</question>
        <stage>cont</stage>
        <default>255.255.255.0</default>
    </ask>

    <ask>
        <dialog config:type="integer">2</dialog>
        <element config:type="integer">4</element>
        <path>networking,routing,routes,0,gateway</path>
        <question>Enter the server default gateway:</question>
        <stage>cont</stage>
        <default>1.2.3.1</default>

在这里,我想使用上面"Gateway“一节中提供的值,以便在下面使用。假设用户在上面提供了192.168.10.100作为网关,它应该存储在一个变量中,并且我可以将变量名放在下面的arp_ip_target中,以便使用默认网关作为目标。但我不知道该怎么做呢?

代码语言:javascript
复制
<interfaces config:type="list">
       <interface>
          <device>bond0</device>
          <startmode>onboot</startmode>
          <bonding_master>yes</bonding_master>
          <bonding_module_opts>arp_interval=1000 arp_ip_target="**gateway**" mode=1 arp_validate=all</bonding_module_opts>
          <bonding_slave0>eth0</bonding_slave0>
          <bonding_slave1>eth1</bonding_slave1>
          <ipaddr></ipaddr>
          <netmask></netmask>
        </interface>
    </interfaces>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-15 09:16:50

XML不支持引用其他元素或值。

因此,你想要达到的目标是不可能的。如果您想要创建这样的解决方案,您必须将其合并到用于读取和解释该文件的软件中。您可以为它提供自己的语法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31426191

复制
相关文章

相似问题

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