加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 02:07:20 所属栏目:百科 来源:网络整理
导读:我经常在XML文件中找到这个奇怪的CDATA标签: ![CDATA[]] 我观察到这个CDATA标签总是在开始,然后是一些东西。 但有时它被使用,有时它不是。我假设是标记一些数据将插入之后。但是什么样的数据?是不是我写的XML标签的某种数据? CDATA代表 Character Data
我经常在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).
]]>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读