忽略 ruby 中嵌入的引号
我不太确定发生了什么,但我正在写入的 xml 文件有这样的内容:
This "is" now my String
当它应该如下所示:
This "is" now my String
这是代码,但我在编译时无法访问实际的字符串。有没有办法告诉 assetName 变量将嵌入的引号视为引号?谢谢。
assetName = 'This "is" now my String'
response.search("property[name=next]").first.andand["value"] = assetName
I'm not exactly sure what is happening, but the xml file I am writing to has this:
This "is" now my String
when it should look like this:
This "is" now my String
Here is the code, except I don't have access to the actual string at compile time. Is there a way to tell the assetName variable to treat embedded quotes as quotes? Thanks.
assetName = 'This "is" now my String'
response.search("property[name=next]").first.andand["value"] = assetName
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 XML 中,引号永远不会出现在属性中,无论用于属性的引号的样式如何。您的 XML 库可能正在为您转义这些引号。
In XML, quotes may never appear in attributes, regardless of the style of the quotes used for the attributes. It is likely that your XML library is escaping these quotes for you.