[Expat-discuss] CdataSectionHandler's

Fred L. Drake, Jr. fdrake at acm.org
Mon Jan 27 09:42:44 EST 2003


antonio.soares at nomadsoft.com writes:
 > I am trying to use the CdataSectionHandler's in th efollowing way:
 > 
 >       Either:
 >             XML_SetStartCdataSectionHandler(p_xml_parser,start_Cdata);
 >             XML_SetEndCdataSectionHandler(p_xml_parser,end_Cdata);
 >       Or:
 >             XML_SetCdataSectionHandler(p_xml_parser,start_Cdata,end_Cdata);
...
 > I cannot obtain any results if parsing something like
 > 
 > <TAG>This is my text</TAG>

It appears that you're missing a little bit about what a CDATA section
is; this example doesn't have one.  This does:

<TAG><![CDATA[This is my text]]></TAG>

and would produce the results you're expecting.

Chances are what you want are the element handlers (see
XML_SetElementHandler()) and the character data handler (see
XML_SetCharacterDataHandler()).  How you would use those depends on
your application.  Most XML consumers do not need the CDATA callbacks;
those are more useful if you need to produce a new XML stream from the
old data, with as much preserved from the original as possible.

 > By the way, , XML_SetCharacterDataHandler(p_xml_parser, xml_data) works
 > fine ..., i.e., I CAN get to "This is my text"


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation



More information about the Expat-discuss mailing list