Name
CDATASection
Synopsis
The CDATASection
interface contains the unparsed, unescaped data
contained within CDATA
blocks
in an XML document. Although this interface inherits the Text
interface, adjacent CDATASection
blocks are not merged by
the normalize( )
method of the
Element
interface.
Java example
// Open an XML source file try { FileInputStream fis = new FileInputStream("phone_list.xml"); StringBuffer sb = new StringBuffer( ); // read the XML source file into memory int ch; while ((ch = fis.read( )) != -1) { sb.append((char)ch); } // now, create a CDATASection object to contain it within // an element of our document using the CDATA facility CDATASection ndCDATA = doc.createCDATASection(sb.toString( )); } catch (IOException e) { ...
CDATASection
is a pure
subclass of the Text
interface
and has no attributes or methods of its own. See the Text interface section of this chapter
for a list of applicable methods for accessing character data in
nodes of this type.
Get XML in a Nutshell, 3rd 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.