官方的XML保留字符是什么? [英] What are the official XML reserved characters?

查看:144
本文介绍了官方的XML保留字符是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此页面中, Microsoft说XML保留字符(及其实体)为以下字符:

In this page, Microsoft says that XML reserved characters (and their entity) are the following ones:

>    >
<    &lt;
&    &amp;
%    &#37;

但是在

But in this other page, I found that also ' is a reserved character (and its entity is &apos;).

有人可以告诉我一些正式的参考文献吗?其中列出了所有的参考文献,仅列出了XML保留字符?

Can someone indicate me some official reference in which are listed all and only the XML reserved characters?

推荐答案

根据 XML规范,当用作字符内容而不是标记时,必须必须转义的唯一字符是&(如&amp;&#38;&#x26;)和<(如&lt;), &#60;&#x3C;),如果它是序列]]>的一部分,则加上>.此外,必须在单引号属性值中转义单引号(通常为&apos;),在双引号属性值中转义双引号(通常为&quot;),以及在使用的字符编码中无法表示的任何字符要序列化文档,必须将其转义为适当的字符参考.

According to the XML spec, the only characters that must be escaped when used as character content rather than markup are & (as &amp;, &#38; or &#x26;) and < (as &lt;, &#60; or &#x3C;), plus > when it is part of the sequence ]]>. In addition, single quotes must be escaped (typically as &apos;) in single quoted attribute values, and double quotes (typically as &quot;) in double-quoted attribute values, and any character that is not representable in the character encoding used to serialize the document must be escaped as a suitable character reference.

您不必必须在单引号属性中转义双引号,反之亦然,但这不会造成任何危害.

You don't have to escape double quotes in single quoted attributes or vice versa, but it won't do any harm if you do so.

当然,您可以 随意转义字符内容中的每个>"'(以及其他任何字符),而无需更改其含义.

Of course, you may escape every >, " and ' (and any other character) within character content if you want to, without changing the meaning.

这篇关于官方的XML保留字符是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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