SAX questions...

Timothy Grant tjg at
Tue Jul 22 19:22:09 CEST 2003

I've worked with DOM before, but never SAX, I have a script that seems to work 
quite well, but every time I look at it I think it's amazingly unweildly and 
that I must be doing something wrong. 

def startElement(self, name, attr):
    if name == "foo":
    elif name == "bar":
    elif name == "baz":

There's similar code in endElement() and characters() and of course, the more 
tags that need processing the more unweildly each method becomes.

I could create a dictionary and dispatch to the correct method based on a 
dictionary key. But it seems to me there must be a better way.

Is there?

Stand Fast,

Timothy Grant

More information about the Python-list mailing list