[XML-SIG] xmllib on expat

Greg Stein gstein@lyra.org
Fri, 21 Jan 2000 18:48:51 -0800 (PST)


On Fri, 21 Jan 2000, Paul Prescod wrote:
>...
> Here's my code:
> 
> import pyexpat
> 
> parser = pyexpat.ParserCreate()
> def show( *x ):
> 	print x
> 
> parser.StartElementHandler=show
> parser.EndElementHandler=show
> parser.CharacterDataHandler=show
> parser.ProcessingInstructionHandler=show
> 
> data=open( "hamlet.xml" ).read()
> parser.Parse( data, 0 )

Try changing that 0 to a 1... meaning "end of input." It may be possible
that Expat is buffering the input for some weird reason.

Otherwise, the code looks fine to me. qp_xml uses pyexpat if you want a
short, simple reference.

  http://www.lyra.org/greg/python/qp_xml.py

>...
> Also, I'm having trouble with pyexpat sometimes hanging depending on the
> buffer length. That code needs a general cleanup but its only 500 lines
> so we're not talking alot of code.

Never seen this.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/