[XML-SIG] xmllib on expat

Paul Prescod paul@prescod.net
Fri, 21 Jan 2000 03:38:01 -0800


I had just decided to do this "xmllib on top of PyExpat" idea this
afternoon! I was planning to make big changes to pyexpat but then it
looked like I wouldn't have to. The interfaces are pretty close. But I'm
actually having trouble getting PyExpat to work at all. Am I doing
something stupid?

I wanted to get it out tonight but it is getting very late so I'll have
to figure it out on a plane tomorrow and send it Saturday morning. :(

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 )

Nothing happens. Nothing ever gets printed.

I've already written the xmllib on pyexpat code so if I can get this
little example to work, I would be home free.

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.

-- 
 Paul Prescod  - ISOGEN Consulting Engineer speaking for himself
Earth will soon support only survivor species -- dandelions, roaches, 
lizards, thistles, crows, rats. Not to mention 10 billion humans.
	- Planet of the Weeds, Harper's Magazine, October 1998