Baseline Widely available
createCDATASection()
creates a new CDATA section node, and returns it.
data
A string containing the data to be added to the CDATA Section.
A CDATA Section node.
Examplesconst doc = new DOMParser().parseFromString("<xml></xml>", "application/xml");
const cdata = doc.createCDATASection("Some <CDATA> data & then some");
doc.querySelector("xml").appendChild(cdata);
console.log(new XMLSerializer().serializeToString(doc));
// Displays: <xml><![CDATA[Some <CDATA> data & then some]]></xml>
Notes
NOT_SUPPORTED_ERR
.NS_ERROR_DOM_INVALID_CHARACTER_ERR
exception if one tries to submit the closing CDATA sequence (]]>
) as part of the data, so unescaped user-provided data cannot be safely used without this method getting this exception (createTextNode()
can often be used in its place).RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4