[Expat-discuss] CDATA and newlines

rolf at pointsman.de rolf at pointsman.de
Thu Mar 24 18:53:32 CET 2005


On 24 Mar, Mark Williams wrote:

[Jani Pellikka wrote:],
>> Expat parser seems to remove all newlines and other
>> white space from between the XML tags. I had understood
>> that with CDATA tag all the material inside would be left
>> as it were but even then the parser removes all newlines.
>> Is there any way to preserve all the material inside CDATA
>> tag untouched with Expat parser?
> 
> I had the same issue.  Expat is correct -- newlines are not saved
> in CDATA sections.  My solution was to use normal text with character
> escapes for the newlines.

Err, what? Surely will newlines are reported to the handler
(normalized to a line-feed (#xA)). What excat location within the xml
recommendation gave you the impression, that newlines within CDATA
sections are discarded?

And from all what I can tell, expat does this right - I get
line-breaks even within CDATA sections. Without seeing his
characterDataHandler code I can only guess, why the original poster
have its problem.

rolf




More information about the Expat-discuss mailing list