SAX parse string to Handler??

Juliano Freitas jubafre at atlas.ucpel.tche.br
Mon Nov 8 05:29:52 EST 2004


hello!!!

here is my pythn code that's handle a xml file:

=============================================================
from xml.sax import saxutils, saxlib, saxexts, parseString

class swdbHandler(saxlib.DocumentHandler):
        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"

parser = saxexts.make_parser()
parser.setDocumentHandler(swdbHandler())

# here
parser.parseFile(open("exemplo.xml"))
=============================================================

i want to parse a "xml string", not a file how can i'm passing in my
swdbHandler. How cai i parse a xml string?? 
somebody can help me with this??

Juliano Freitas




More information about the Python-list mailing list