如何使用命令提示符echo命令编写带有双引号的XML标签 [英] How to write an XML tag with double quotes using command prompt echo command

查看:280
本文介绍了如何使用命令提示符echo命令编写带有双引号的XML标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用CMD批处理文件将最简单的标签添加到文件中,但是似乎双引号破坏了聚会:

I would like to add the simpliest tag into a file, using a CMD batchfile, but it seems that the double quotes are spoiling the party:

从其他StackOverflow帖子中,我知道双引号状态机和^(^作为转义符)的用法.但我仍然无法使它起作用:
在此我的尝试(及其结果):

From other StackOverflow posts I am aware of the double quote state machine and the usage of ^" (^ as an escape character). Still I can't make it work:
Hereby my attempts (with their results):

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="...")并不能解决问题.
如前所述,我越来越绝望了.我唯一要做的就是将其写入文本文件:

I have also done some tests using the escape character in front of the tag characters < and > (as those have their own significance in CMD) but also there no good results.
Also first putting the entry within a variable (set test="...") does not solve the issue.
As mentioned, I am getting desperate. The only thing I want to do is writing this into a text file:

<tag variable="value">

有人可以帮我吗?
预先感谢

Can anybody help me out here?
Thanks in advance

推荐答案

您要转义的字符不是"而是<.
那么正确的语法就是这个:

the characters you want to escape are not the " but the <.
Then the correct syntax is this one :

C:\>echo ^<tag variable="value"^>

这篇关于如何使用命令提示符echo命令编写带有双引号的XML标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆