I think your problem is not a problem of XML programming, but a conceptual one. The thing is: CDATA section is not a part of XML logical structure. From the logical structure perspective, such thing simply does not exist. CDATA is merely an expressive tool used to enter character data containing XML markup characters.
Consider these two XML code samples:
This is some HTML code sample: <p>Paragraph</p>
When these fragments are parsed by a standard XML parser, for example, into DOM structure, no difference between them can be found. From the standpoint of logical structure, they are the same. First sample uses CDATA, second one — XML character entities
. Both methods are used to "escape" XML markup characters '
' and '
; CDATA is simply a shorter way to write the same thing. Both have nothing to do with logical structure. They simply don't have to be "sent".