代码之家  ›  专栏  ›  技术社区  ›  goku_da_master

在读取字符串中的分号时,Nant脚本中的xmlpoke出现问题

  •  2
  • goku_da_master  · 技术社区  · 15 年前

    我有一个nant脚本试图在web.config中更改一个url值,但是nant不断抛出这个错误:

    '=' is an unexpected token. The expected token is ';'. Line 1, position 80.
    

    我把它追溯到了nant脚本的URL中的分号。首先,我在URL中使用分号的原因是web.config不喜欢使用分号(&)。所以我不得不用 & . 这是我的web.config值:

    <appSettings>
        <add key="myUrl" value="http://www.google.com/whatever?id=myId&amp;fullScreen=1"/>
    </appSettings>
    

    我可以在web.config中使用xmlpoke来添加所有其他的“添加键”,但这一个除外,所以这不是一个xpath问题。 这是南特剧本:

    <property name="myUrl" value="http://www.google.com/whatever?id=123456&amp;fullScreen=2"/>
    
    <xmlpoke 
       file="${config.file}"
       xpath="/configuration/appSettings/add[@key = 'myUrl']/@value"
       value="${myUrl}">    
    </xmlpoke>
    

    所以问题不在于web.config中的分号,而在于nant脚本中的分号。我想我需要以某种方式避开南特脚本中的分号。有人知道怎么做或做其他什么来让它工作吗?

    1 回复  |  直到 13 年前
        1
  •  5
  •   Leigh josh poley    13 年前

    已经16个小时了,没有人偷看。幸运的是,我在谷歌搜索了几个小时后找到了解决方案。

    解决方案是使用 &amp;amp; . 我不知道为什么额外的 amp; 但它奏效了。 所以现在我的南特剧本看起来是这样的:

    <property name="myUrl" value="http://www.google.com/whatever?id=123456&amp;amp;fullScreen=2"/>
    

    信用证转到 Gary from the nant-users mailing list ,我刚刚订阅了:)

    推荐文章