CDATA Sections

CDATA sections don't mean anything; they are strictly a convenience to make XML document authors' lives easier. Suppose I want to include an example of some XML in an XML document (this isn't that uncommon, after all I'm about to do it right now). There are two ways I could do this:

<tag>Hello, world!</tag>


<![CDATA[<tag>Hello, world!</tag>]]>

These encode strictly identical data, and there is nothing wrong with either. The CDATA technique, though, is probably a lot more convenient for an author, because she can cut chunks of XML out of other documents and drop them right into the CDATA section, without having to worry about escaping all those < and & characters.

Back-link to spec

Copyright © 1998, Tim Bray. All rights reserved.