From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/document/createcdatasection/index.html | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 files/zh-cn/web/api/document/createcdatasection/index.html (limited to 'files/zh-cn/web/api/document/createcdatasection') diff --git a/files/zh-cn/web/api/document/createcdatasection/index.html b/files/zh-cn/web/api/document/createcdatasection/index.html new file mode 100644 index 0000000000..298e0021fb --- /dev/null +++ b/files/zh-cn/web/api/document/createcdatasection/index.html @@ -0,0 +1,67 @@ +--- +title: Document.createCDATASection() +slug: Web/API/Document/createCDATASection +tags: + - API + - DOM + - 参考 + - 方法 +translation_of: Web/API/Document/createCDATASection +--- +
{{APIRef("DOM")}}
+ +

createCDATASection() 创建并返回一个新的 CDATA 片段节点。

+ +

语法

+ +
var CDATASectionNode = document.createCDATASection(data);
+
+ + + +

示例

+ +
var docu = new DOMParser().parseFromString('<xml></xml>', 'application/xml');
+
+var cdata = docu.createCDATASection('Some <CDATA> data & then some');
+
+docu.getElementsByTagName('xml')[0].appendChild(cdata);
+
+alert(new XMLSerializer().serializeToString(docu));
+// Displays: <xml><![CDATA[Some <CDATA> data & then some]]></xml>
+
+ +

备注

+ + + +

规范

+ + + + + + + + + + + + + + + + +
规范状态备注
{{SpecName('DOM WHATWG', '#dom-document-createcdatasection', 'document.createCDATASection')}}{{Spec2('DOM WHATWG')}}
+ +

浏览器兼容性

+ + + +

{{Compat("api.Document.createCDATASection")}}

-- cgit v1.2.3-54-g00ecf