[XML-SIG] How do I process CDATA when the characters looks like XML

Mike Brown mike@skew.org
Wed, 14 May 2003 12:19:33 -0600 (MDT)


William McLendon wrote:
> I'm working with the basic python SAX parser (xml.sax.handler, etc) and am 
> needing to process some XML that has "<" and ">" characters going in CDATA 
> fields.
> 
> For example, the model I want to have is this:
> 
> <A>X</A>  where "X" is some kind of character data.
> 
> but if X = <B> giving me this situation:
> 
> <A><B></A>

If you're wanting to put markup characters "<" or "&" in character data, you
must escape them, either using character or entity references, or the special
markup for a CDATA section:

<A>&lt;B></A>  (escaping the > is optional)
or
<A><![CDATA[<B>]]></A>