- XML Tutorial
- XML - Home
- XML - Overview
- XML - Syntax
- XML - Documents
- XML - Declaration
- XML - Tags
- XML - Elements
- XML - Attributes
- XML - Comments
- XML - Character Entities
- XML - CDATA Sections
- XML - White Spaces
- XML - Processing
- XML - Encoding
- XML - Validation
- Advance XML
- XML - DTDs
- XML - Schemas
- XML - Tree Structure
- XML - DOM
- XML - Namespaces
- XML - Databases
XML - CDATA Sections
In this chapter, we will discuss XML CDATA section. The term CDATA means, Character Data. CDATA is defined as blocks of text that are not parsed by the parser, but are otherwise recognized as markup.
The predefined entities such as &lt;, &gt;, and &amp; require typing and are generally difficult to read in the markup. In such cases, CDATA section can be used. By using CDATA section, you are commanding the parser that the particular section of the document contains no markup and should be treated as regular text.
Following is the syntax for CDATA section −
<![CDATA[ characters with markup ]]>
The above syntax is composed of three sections −
CDATA Start section − CDATA begins with the nine-character delimiter <![CDATA[
CDATA End section − CDATA section ends with ]]> delimiter.
CData section − Characters between these two enclosures are interpreted as characters, and not as markup. This section may contain markup characters (<, >, and &), but they are ignored by the XML processor.
The following markup code shows an example of CDATA. Here, each character written inside the CDATA section is ignored by the parser.
<script> <![CDATA[ <message> Welcome to TutorialsPoint </message> ]] > </script >
In the above syntax, everything between <message> and </message> is treated as character data and not as markup.
The given rules are required to be followed for XML CDATA −
- CDATA cannot contain the string "]]>" anywhere in the XML document.
- Nesting is not allowed in CDATA section.
Kickstart Your Career
Get certified by completing the courseGet Started