CDATA section |
A CDATA section or character data section is a section in an XML document which is marked for the parser to interpret as character data and not markup. A CDATA section starts with the following sequence:
<![CDATA[
and ends with the first occurrence of the sequence:
]]>
All characters enclosed between these two sequences are interpreted as characters, not markup or entity references. For example, in a line like this:
<sender>John Smith</sender>
the opening and closing sender tags are interpreted as markup. If, however, they are written like this:
<![CDATA[<sender>John Smith</sender>]]>
they will have exactly the same status as John Smith —text. Similarly, if ð appears in an XML document normally, it will be parsed as a reference for the Unicode character U+00F0 (small letter eth), but if the same appears in a CDATA section, it will be parsed as ampersand, hash mark, digit 2, digit 4, digit 0, semicolon.
CDATA sections are useful for writing XML code as data. For example, if one wishes to typeset a book with Extensible Stylesheet Language explaining the use of an XML application, the XML markup to appear in the book itself will be written in the source file in a CDATA section. However, a CDATA section cannot contain the string ]]> and therefore it is not possible for a CDATA section to contain nested CDATA sections.|
|
