Java APIs for XML Kick Start By Aoyon Chowdhury, Parag Choudhary
Table of Contents
Appendix B. XML: A Quick Tour
In the discussion about predefined entities you learned how to escape markup characters by using predefined entities. This solution works when there are small numbers of such characters to be escaped, although it becomes tedious when there are a large number of such characters that need to be escaped. Other than this, there might also be times when you want the XML parser to output the text exactly as it appears in the XML document. Such a need often arises when you want to send the output of one XML document as an input to another application.
To handle such a situation, XML provides the CDATA section. The XML parser will not treat any text that appears between these two entries as markup. The way to provide information in a CDATA section is as follows:
<![CDATA[text to be kept as is]]>
The CDATA section begins with <![CDATA[ and ends with ]] >. In our example, the CDATA is used in the forCDATA element (as shown in the next section) to avoid escaping the huge number of >, <, and other markup characters.