Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > SAX questions...

Reply
Thread Tools

SAX questions...

 
 
Timothy Grant
Guest
Posts: n/a
 
      07-22-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":
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SAX Ike Java 2 07-09-2003 04:42 AM
Re: OutOfMemoryError when using SAX to process an XML document Robert Olofsson Java 3 07-03-2003 10:36 AM
Re: Illegal XML character SAX Parser exception William Brogden Java 1 06-30-2003 06:11 AM
Re: Illegal XML character SAX Parser exception Michael Lee Java 0 06-27-2003 03:12 PM



Advertisments