When do I need to use the " in xml?
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?
Exhibit A
<boat>
<name> Bertha </name>
<description> Good boat. 10 feet long. "Fixer-upper"</description>
</boat>
Exhibit B
<boat>
<name> Bertha </name>
<description> Good boat. 10 feet long. &开发者_如何学JAVA;quot;Fixer-upper"</description>
</boat>
Both of your examples are valid.
You only need "
inside an attribute value; a "
character would close the attribute early.
From MSDN:
"
must be used for an attribute value, but a straight quotation mark (") is acceptable as the content of an element.
Both are correct and valid XML.
There is no need to use "e;
within text nodes.
like this is ok
<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>
精彩评论