SAX parse string to Handler??

Alan Kennedy alanmk at hotmail.com
Mon Nov 8 12:20:51 CET 2004


[Juliano Freitas]
 > here is my pythn code that's handle a xml file:

Juliano,

I think you're better off using the standard sax parsing facilities than 
those inside saxexts, etc.

Try this code

#==================================================
import xml.sax

class swdbHandler(xml.sax.handler.ContentHandler):
     def __init__(self):
         self.flag = 0

     def startElement(self, name, atts):
         if name == "swml":
             print "enter"

     def endElement(self, name):
         if name == "swml":
             print "exit"

xml_string="<swml><contents/></swml>"

xml.sax.parseString(xml_string, swdbHandler())
#==================================================

HTH,

-- 
alan kennedy
------------------------------------------------------
email alan:              http://xhaus.com/contact/alan



More information about the Python-list mailing list