Setting a CDATA handler in Expat

Frank Moore <[email protected]>
Newsgroups gmane.text.xml.expat.general
Message-ID <[email protected]>
Hi,

Can anyone tell me how to set a CDATA event handler in Python using Expat.
I'm currently using the Expat XML Parser (version 1.95.5).
And this is the Python code:

      outFile = file(localPlayerHtml, 'w')
      inFile = file(tempPlayerHtml, 'r')
      htmlparser = saxexts.make_parser()
      htmlhandler = PlayerHtmlHandler(outFile, stream)
      htmlparser.setDocumentHandler(htmlhandler)
      htmlparser.StartCdataSectionHandler = 
PlayerHtmlHandler.startCDATA     <-- here
      htmlparser.EndCdataSectionHandler = 
PlayerHtmlHandler.endCDATA       <-- and here
      htmlparser.parseFile(inFile)

The class PlayerHtmlHandler(saxlib.HandlerBase) in file 
PlayerHtmlHandler.py contains the following two functions:

   def startCDATA(self):
     print "Starting CDATA..."
     
   def endCDATA(self):
     print "Finishing CDATA..."

And I'm including the contents of PlayerHtmlHandler using the import 
statement:

from PlayerHtmlHandler import *

For some reason when I run the code, the two CDATA handlers are not called.

Can anyone see what I'm doing wrong?

Many thanks,
Frank.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.