我什么时候需要使用 " 在 xml 中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5186179/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
When do I need to use the " in xml?
提问by sixtyfootersdude
When I have quotes that are not in an attribute do I need to encode them using "?
当我有不在属性中的引号时,我需要使用 对它们进行编码"吗?
Which is correct? Exhibit A or Exhibit B?
哪个是正确的?图A还是图B?
Exhibit A
附件 A
<boat>
<name> Bertha </name>
<description> Good boat. 10 feet long. "Fixer-upper"</description>
</boat>
Exhibit B
附件 B
<boat>
<name> Bertha </name>
<description> Good boat. 10 feet long. "Fixer-upper"</description>
</boat>
回答by SLaks
Both of your examples are valid.
你的两个例子都是有效的。
You only need "inside an attribute value; a "character would close the attribute early.
你只需要"在一个属性值里面;一个"字符会早早关闭属性。
回答by chiper
回答by chuan
like this is ok
<boat description = " Good boat. 10 feet long. "Fixer-upper""></boat>
这样就可以了
<boat description = " Good boat. 10 feet long. "Fixer-upper""></boat>
like this is not ok
<boat description = " Good boat. 10 feet long. "Fixer-upper""></boat>
这样不行
<boat description = " Good boat. 10 feet long. "Fixer-upper""></boat>
回答by Oded
Both are correct and valid XML.
两者都是正确且有效的 XML。
There is no need to use "e;within text nodes.
无需"e;在文本节点内使用。

