[XML-SIG] Returning data from DocumentHandler

Andrew M. Kuchling akuchlin@mems-exchange.org
Thu, 24 Feb 2000 17:19:50 -0500 (EST)


Bradley Marshall writes:
>class DocHandler(DocumentHandler):
>....
>    def endDocument(self):
>	return self.data
>
>dh = docHandler()
>p = parser()
>p.setDocumentHandler(dh)
>data = p.parseFile(file)
>p.close()

The parseFile() method doesn't return anything, so it'll always be
None.  In the Java version of SAX, the parse() method is declared as
void, in other words.  Why not just access the attribute .data of your
DocHandler class?  You can also add an accessor method,
.getWhateverData(), to your class, if you prefer accessor methods to
attributes.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
Perhaps God made cats so that man might have the pleasure of fondling the
tiger...
    -- Robertson Davies, _The Diary of Samuel Marchbanks_