Next / Previous / Contents / TCC Help System / NM Tech homepage

9.  The CharacterData classes: Text, CDATA, and Comment

This class is a base class for nodes that hold strings of text. All strings are represented as 16-bit Unicode characters; use str() if you need to coerce them to 8-bit character strings.

There are three classes derived from CharacterData: Text for text children of elements, CDATA for CDATA sections, and Comment for XML comments.

Its attributes include:

.data

The content of the node as a string.

.length

The length of the content in characters.

Methods defined on CharacterData objects are enumerated below.

9.1. CharacterData.appendData()

Use this method to append text from a string s to a CharacterData object C.

C.appendData(s)