【问题标题】:Ant Replacing a specific occurrence in xmlAnt替换xml中的特定事件
【发布时间】:2012-07-17 15:10:28
【问题描述】:

我有如下的 xml,我想使用 Ant 更改某个值的特定出现(尝试了 replaceregexp,但没有太大帮助,因为它发现了多次出现,replace 也替换了多次出现)并且我们没有集成 xmltask。

<databases>
 <database>
    <server>mssql_1</server>
    <port>1433</port>
   <sid_instance>foobar</sid_instance>
   <path></path>
   <hostuser>sa</hostuser>
   <hostpwd>password</hostpwd>
 </database>
<database>
  <server>oracle_1</server>
  <port>1521</port>
  <sid_instance>foobar</sid_instance>
  <path>C:\\oracle\\oradata\\foobar</path>
  <hostuser>system</hostuser>
  <hostpwd>password</hostpwd>
 </database>
</databases>

【问题讨论】:

    标签: xml ant replace


    【解决方案1】:

    我会插入XMLTask,因为这正是它的设计目的!您不能将其加载到(例如)您的主目录并按照this SO answer 提供类路径引用吗?

    (作为XMLTask的作者)

    【讨论】:

      【解决方案2】:

      希望this link能帮到你。它解释了如何使用xmlTask 执行此操作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-06-20
        • 2011-05-01
        • 1970-01-01
        • 2021-01-02
        • 1970-01-01
        • 2011-10-31
        • 1970-01-01
        • 2014-03-11
        相关资源
        最近更新 更多