Cdata in XML

CDATA

When creating XML documents, sometimes there are blocks of text that contain characters that may prove to be a problem when trying to validate the document. An example of this would be if the XML data contains a programming script, many of which contain characters such as >, <, &, etc, which will likely cause problems for the XML processor.  To avoid this, CDATA can be used to eliminate the need to go through the entire script.  During validation, the XML processor skips all data between the CDATA tags.  The syntax for CDATA is shown in the example below:

Example: <root_element>

<element>

<![CDATA[

Text and script that should be skipped

]]>

</element>

</root_element>

This entry was posted in XML Tutorial. Bookmark the permalink.

Leave a Reply

Your email address will not be published.