About ![CDATA[, what is it? [duplicate] About ![CDATA[, what is it? [duplicate] xml xml

About ![CDATA[, what is it? [duplicate]


It is a way to escape large sections of text in XML documents.

From wikipedia:

In an XML document or external parsed entity, a CDATA section is a section of element content that is marked for the parser to interpret as only character data, not markup.

By the way, it is <![CDATA[]]>, not ![CDATA[]].


The term CDATA ((Unparsed) Character Data) is used about text data that should not be parsed by the XML parser.

Some text, like JavaScript code, contains a lot of "<" or "&" characters. To avoid errors script code can be defined as CDATA.

Ref


CDATA is used in XML (and hence XHTML) to insert text which might include "special" characters (eg. < and >) which would normally break the XML parser (and to be fair, confuse a human reader, as well!).

For example, you could use it to embed a code segment inside an XML document.