什么是CDATA和它做什么? [英] What exactly is CDATA and what does it do?

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

问题描述

我有时会注意到包含<![CDATA []]> 标签。我找不到任何解释。 CDATA是什么?为什么某些人使用它,需要什么?

I sometimes notice a CSS or JS code surrounded with <![CDATA[ and ]]> tags. I couldn't find any explanation to this. What does CDATA do? Why is it used by some people and what is it needed for?

推荐答案

它告诉解释器它不应该尝试解释标签中包含的数据。例如,如果您想让XML文件包含带<或>,则XML解释器将该文件报告为无效,和>不会是标准标记的一部分。你只需要用CDATA标签包围代码。

It tells the interpreter that it should not try to interpret the data enclosed in the tags. For example, if you want a XML file to contain a comment with < or >, XML interpreters will report the file as invalid because the caracters < and > will not be part of standard tag. You simply have to surround the code with the CDATA tags.

这篇关于什么是CDATA和它做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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