CDATASection
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
CDATASection
接口用于表示 CDATA 片段(CDATA section)。在 XML 中,CDATA 可以直接包含未经转义的文本。比如 <
和 &
,只要位于 CDATA 片段中,它们就不需要被转义,保持原样就可以了。
在 XML 中,一个 CDATA 片段格式如下:
xml
<![CDATA[ … ]]>
例如:
html
<foo>
这是一个 CDATA 片段:<![CDATA[ < > & ]]> 其中包含了一些没有转义的字符。
</foo>
唯一的例外就是,在一个 CDATA 片段中不可以使用 CDATA 片段本身的闭合标签片段:
xml
<![CDATA[ ]]> 会引发错误 ]]>
注意,CDATA 片段不应该在 HTML 中被使用;它只在 XML 中有效。
must be a string
属性
这个接口没有特有的属性,但实现了父接口 Text
的属性。
方法
这个接口没有特有的方法,但实现了父接口 Text
的方法。
规范
Specification |
---|
DOM # interface-cdatasection |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
CDATASection |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
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.