CDATA (literally, character data) is data that will not be parsed as markup in XML and SGML documents.
While technically "all text that is not markup constitutes the character data" of an XML document (and a similar definition applies for SGML), the term CDATA is typically used in the context of CDATA sections.
A CDATA section begins with the string <![CDATA[
and ends with the string ]]>
. The data inside a CDATA section is not parsed as markup within an XML or SGML document - which can be useful when representing XML or SGML within an XML or SGML document:
<![CDATA[
<html>
<head>
<title>This is not markup ...</title>
</head>
<body>
<p>... and neither is this.</p>
</body>
</html>
]]>
A CDATA section may contain any sequence of characters except for the string ]]>
(which would terminate the section). One way to work around this limitation is to terminate the CDATA section after the string ]]
and then begin a new one immediately, starting with the final >
. For instance,
<![CDATA[How to represent ']]]]><![CDATA[>' inside a CDATA section.]]>
is equivalent to
How to represent ']]>' inside a CDATA section.