May 27, 2021 19:00 XML

Table of contents


This section is about XML CDATA, which refers to character data, which we define as blocks of text.

All text in the XML document is parsed by the parser.

Only the text in the CDATA segment is ignored by the parser.

PCDATA - Parsed character data

XML parsers typically parse all the text in an XML document.

When an XML element is parsed, the text between its labels is also parsed:

<message>This text is also parsed</message>

The parser does this because the XML element can contain other elements, just as in this instance, where the element contains two other elements (first and last):


The parser breaks it down into child elements like this:


Parsing character data (PCDATA) is a term used by XML parsers to parse text data.

CDATA - (unresolved) character data

The term CDATA is text data that should not be parsed by an XML parser.

Characters such as ""

An error occurs because the parser interprets the character as the beginning of the new element.

An error occurs because the parser interprets the character as the beginning of the character entity.

Some text, such as JavaScript code, contains a large number of "" To avoid errors, you can define the script code as CDATA.

Everything in the CDATA section is ignored by the parser.

CDATA is partly composed of the " slt;! CDATA " starts, ends with "

function matchwo(a,b)
if (a < b && a < 0) then
return 1;
return 0;

In the example above, the parser ignores everything in the CDATA section.

Notes on the CDATA section:

The CDATA section cannot contain the string " . Nested CDATA sections are also not allowed.

Mark the ""

The comments in the CDATA section above are the rules you need to follow for XML CDATA!

In the next section, we'll cover XML coding.