微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

XML中的<![CDATA []]>是什么意思?

我经常在XML文件中找到这个奇怪的CDATA标签
<![CDATA[]]>

我观察到这个CDATA标签总是在开始,然后是一些东西。

但有时它被使用,有时它不是。我假设是标记一些数据将插入之后。但是什么样的数据?是不是我写的XML标签的某种数据?

CDATA代表 Character Data,这意味着这些字符串之间的数据包括可以解释为XML标记的数据,但不应该。

CDATA和注释之间的主要区别是:

> As Richard points out,CDATA仍然是文档的一部分,而注释不是。
>在CDATA中,您不能包括字符串]]> (CDEnd),而在评论-- is invalid
> Parameter Entity在注释内部无法识别引用。

这意味着从一个格式良好的文档中提供这三个XML片段:

<!ENTITY MyParamEntity "Has been expanded">
<!--
Within this comment I can use ]]>
and other reserved characters like <
&,',and ",but %MyParamEntity; will not be expanded
(if I retrieve the text of this node it will contain
%MyParamEntity; and not "Has been expanded")
and I can't place two dashes next to each other.
-->
<![CDATA[
Within this Character Data block I can
use double dashes as much as I want (along with <,&,and ")
*and* %MyParamEntity; will be expanded to the text
"Has been expanded" ... however,I can't use
the CEND sequence (if I need to use it I must escape one of the
brackets or the greater-than sign).
]]>

原文地址:https://www.jb51.cc/xml/294360.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。