官方的XML保留字符是什么? [英] What are the official XML reserved characters?
问题描述
在此页面中, Microsoft说XML保留字符(及其实体)为以下字符:
In this page, Microsoft says that XML reserved characters (and their entity) are the following ones:
> >
< <
& &
% %
But in this other page, I found that also '
is a reserved character (and its entity is '
).
有人可以告诉我一些正式的参考文献吗?其中列出了所有的参考文献,仅列出了XML保留字符?
Can someone indicate me some official reference in which are listed all and only the XML reserved characters?
推荐答案
根据 XML规范,当用作字符内容而不是标记时,必须必须转义的唯一字符是&
(如&
,&
或&
)和<
(如<
), <
或<
),如果它是序列]]>
的一部分,则加上>
.此外,必须在单引号属性值中转义单引号(通常为'
),在双引号属性值中转义双引号(通常为"
),以及在使用的字符编码中无法表示的任何字符要序列化文档,必须将其转义为适当的字符参考.
According to the XML spec, the only characters that must be escaped when used as character content rather than markup are &
(as &
, &
or &
) and <
(as <
, <
or <
), plus >
when it is part of the sequence ]]>
. In addition, single quotes must be escaped (typically as '
) in single quoted attribute values, and double quotes (typically as "
) 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屋!