读取字符串中的分号时,nant 脚本中的 xmlpoke 出现问题
我有一个 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&fullScreen=1"/>
</appSettings>
我可以在 web.config 中对所有其他“添加键”进行 xmlpoke,但这个除外,所以这不是 xpath 问题。 这是 nant 脚本:
<property name="myUrl" value="http://www.google.com/whatever?id=123456&fullScreen=2"/>
<xmlpoke
file="${config.file}"
xpath="/configuration/appSettings/add[@key = 'myUrl']/@value"
value="${myUrl}">
</xmlpoke>
所以问题不在于 web.config 中的分号,而在于 nant 脚本中的分号。我想我需要以某种方式转义 nant 脚本中的分号。有人知道如何执行此操作或其他操作以使其正常工作吗?
I have a nant script that is trying to change a URL value in my web.config but Nant keeps throwing this error:
'=' is an unexpected token. The expected token is ';'. Line 1, position 80.
I traced it down to the semicolon in the URL of the nant script. The reason I have a semicolon in the URL in the first place is because the web.config doesn't like ampersands (&). So I had to replace & with &
. Here's my web.config value:
<appSettings>
<add key="myUrl" value="http://www.google.com/whatever?id=myId&fullScreen=1"/>
</appSettings>
I'm able to xmlpoke all the other "add keys" in the web.config but this one, so it's not an xpath issue.
Here's the nant script:
<property name="myUrl" value="http://www.google.com/whatever?id=123456&fullScreen=2"/>
<xmlpoke
file="${config.file}"
xpath="/configuration/appSettings/add[@key = 'myUrl']/@value"
value="${myUrl}">
</xmlpoke>
So the problem isn't with the semicolon in the web.config, but with the semicolon in the nant script. I guess I need to somehow escape the semicolon in the nant script. Anyone know how to do this or something else to get it to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已经16个小时过去了,没有人听到任何消息。对我来说幸运的是,经过几个小时的谷歌搜索后我找到了解决方案。
解决方案是使用
&
。我不知道为什么需要额外的amp;
但它有效。所以现在我的 nant 脚本看起来像这样:
功劳归于 来自 nant-users 邮件列表的 Gary,我刚刚订阅了:)
It's been 16 hours and not a peep from anyone. Lucky for me I found the solution after a few hours of googling.
The solution is to use
&
. I have no idea why the extraamp;
but it worked.So now my nant script looks like so:
The credit goes to Gary from the nant-users mailing list, which I just subscribed to :)