[Pythonmac-SIG] XML handler design

Henning.Ramm at mediapro-gmbh.de Henning.Ramm at mediapro-gmbh.de
Thu Mar 24 15:22:15 CET 2005

>> And where should the "output" go to?
>> All examples use print statements in the element handlers.
>I'm not certain we are clear. Instead of output statements you 
>store the data in some instance variable - in your case it appears 
>self.pages is your instance variable containing the data.


>So your 
>endElement method would set something in self.pages based on the tag 
>indicated and the data built up from the characters method and any of 
>the attrs from the start tag. If all your data is in the attrs 
>that you 
>get in the startElement tag then there's no need to do anything in the 
>characters or endElement methods.  If you want to use the 
>startElement/characters/endElement approach, I can try to find a small 
>example I've written and send it to you off-list.

I need the different element handlers (start, end and characters) to
collect lots of small data parts that are spread all over the file
and make a series of objects from it (stored in self.pages).

My first attempt used DOM, but I get a cleaner, more readable, better
extendable code with SAX. And I guess it's easier to make a SAX parser

I'd be interested in your code, if you were so kind.
(I'm on going in holidays now, so I guess you'll get an out of office
reply, but I'll read my mail sometimes.)

Best regards,
Henning Hraban Ramm
Südkurier Medienhaus / MediaPro
Support/Admin/Development Dept.

More information about the Pythonmac-SIG mailing list