[XML-SIG] Using PyExpat.py
Don Wakefield
don_wakefield@mentorg.com
Fri, 9 Feb 2001 18:05:55 -0800 (PST)
I'm trying to construct a DOM using PyExpat.py. My environment is:
Python 1.5.2
PyXML 0.6.2
Here's the simple code. I've added a few lines like
reader._override = None
to get past errors that I didn't understand until I came to this
point. Now I don't know what more to do...
------------------------------------------
<CODE>
from xml.parsers import pyexpat
from xml.dom.ext.reader import PyExpat
import time
class Cells:
def __init__(self, filename):
try:
reader = PyExpat.Reader()
reader._override = None
fp = open(filename, 'r')
xml_dom_object = reader.fromStream(fp)
except Exception, msg:
print "Exception caught:", msg
return
self.root = xml_dom_object.documentElement
if __name__ == '__main__':
import sys
if len(sys.argv) == 2:
start = time.clock()
x = Cells(sys.argv[1])
end = time.clock()
print "Finished loading:", end - start
else:
print "Usage: python %s [XML-filename]" % sys.argv[0]
</CODE>
Here is the output of a run:
----------------------------
<343 : /user/donw/src/Demo/bigproto> !334
python_ic Time2.py big.xml
Exception caught: pyexpat
Finished loading: 0.0
----------------------------
Can anybody tell me what I'm doing wrong? The goal here is to use
pyexpat.so to speed the building of the DOM. Thanks for any comments.
--
Don Wakefield Mentor Graphics Corporation
(503) 685-1262 8005 S.W. Boeckman Road
don_wakefield@mentorg.com Wilsonville, OR 97070-7777