【发布时间】:2015-10-08 12:04:31
【问题描述】:
我想将最简单的标签添加到文件中,使用 CMD 批处理文件,但似乎双引号破坏了聚会:
从 StackOverflow 的其他帖子中,我知道双引号状态机和 ^" 的用法(^ 作为转义字符)。我仍然无法使其工作:
在此我的尝试(及其结果):
C:\>echo <tag variable="value"> // very naïve
The syntax of the command is incorrect.
C:\>echo "<tag variable="value">" // let's use quotes for delimiting the string
"<tag variable="value">"
C:\>echo "<tag variable=^"value^">" // let's use the escape character
The system cannot find the path specified.
C:\>echo "<tag variable=^"value^"> // what if the state machine is not switched back?
The syntax of the command is incorrect.
C:\>echo "<tag variable=^"value"> // desperate people do weird things :-)
"<tag variable=^"value">
我也做了一些测试,在标签字符 前面使用了转义字符(因为它们在 CMD 中有自己的意义),但也没有很好的结果。
同样首先将条目放入变量 (set test="...") 并不能解决问题。
如前所述,我越来越绝望。我唯一想做的就是将其写入文本文件:
<tag variable="value">
有人可以帮我吗?
提前致谢
【问题讨论】:
-
您应该在帖子(标题和正文)中将“DOS”替换为“CMD”...我想您并没有真正使用 DOS,是吗?
-
@aschipfl:完成。
标签: xml batch-file cmd escaping double-quotes