T
Timothy Grant
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":
do_foo_stuff()
elif name == "bar":
do_bar_stuff()
elif name == "baz":
do_baz_stuff()
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,
tjg.
Timothy Grant
www.craigelachie.org
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":
do_foo_stuff()
elif name == "bar":
do_bar_stuff()
elif name == "baz":
do_baz_stuff()
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,
tjg.
Timothy Grant
www.craigelachie.org