RE: [xml-dev] Tradeoffs of XML encoding by enclosing all content in CDATA blocks

From
Michael Kay <>
To
'Andrew Welch' <>, "'Karr, David'" <>
Date
2008-09-29T15:51:44Z
ID
<D39AE8B4AD944FB284F159C79DCF11FB@Sealion>
Thread
RE: [xml-dev] Tradeoffs of XML encoding by enclosing all content in CDATA blocks
> You often get this problem when people write XML as a string 
> rather than using a proper XML Writer...
> 
> For example:
> 
> xmlStr = "<foo>" + someVal  + "</foo>";
> write(xmlStr);
> 
> The are several problems with this approach, one being that 
> ampersands won't be escaped properly.

I've also seen such code result in a performance bottleneck. It turned out
that generating the XML was taking significantly longer than subsequent
parsing, validating, and transforming of the same XML. It's much more likely
to be optimized if you use a library that has been carefully written by
someone else.

Michael Kay
http://www.saxonica.com/