SAX questions...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Timothy Grant

    SAX questions...

    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(se lf, 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



Working...