CDATASection
接口用于表示 CDATA 片段(CDATA section)。在 XML 中, CDATA 可以直接包含未经转义的文本。比如 <
和 &
,只要位于 CDATA 片段中,它们就不需要被转义,保持原样就可以了。
在 XML 中,一个 CDATA 片段格式如下:
<![CDATA[ ... ]]>
例如:
<foo>这是一个CDATA section: <![CDATA[ < > & ]]> 其中包含了一些没有转义的字符。 </foo>
唯一的例外就是,在一个 CDATA 片段中不可以使用 CDATA 片段本身的闭合标签片段:
<![CDATA[ ]]> 会引发错误 ]]>
注意,CDATA 片段不应该在 HTML 中被使用;它只在 XML 中有效。
属性
这个接口没有特有的属性,但实现了父接口 Text
的属性。
方法
这个接口没有特有的方法,但实现了父接口 Text
的方法。
规范
规范 | 状态 | 备注 |
---|---|---|
DOM CDATASection |
Living Standard | Re-added in issue #295 due to web breakage |
DOM4 CDATASection |
Obsolete | Removed in favour of the more generic Text interface |
Document Object Model (DOM) Level 3 Core Specification CDATASection |
Obsolete | No change from Document Object Model (DOM) Level 2 Core Specification |
Document Object Model (DOM) Level 2 Core Specification CDATASection |
Obsolete | No change from Document Object Model (DOM) Level 1 Specification. |
Document Object Model (DOM) Level 1 Specification CDATASection |
Obsolete | Initial definition |
浏览器兼容性
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.