Character data sections

Ranges of text, possibly containing reserved markup characters that are not to be interpreted as markup, can be enclosed in a character data section. A CDATASection node represents such a text range.

This interface extends the CharacterData interface, and adds no further methods. It is therefore simply used to identify character data nodes. When the value of a CDATASection node is written out to XML, the delimiter markup, '<![CDATA[' and '] ]>' is added.

Creating CDATA sections

A new CDATASection node can be created using the createCDATASection factory method defined in the Document interface:

// <![CDATA[press <ENTER>] ]>

CDATASection newCDATANode =
        myDoc.createCDATASection( "press <ENTER>" );

Get XML Companion, The, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.