[XML-SIG] speed question re DOM parsing

Bjorn Pettersen bjorn@roguewave.com
Wed, 24 May 2000 18:49:39 -0600


Greg Stein wrote:
> 
> On Wed, 24 May 2000, Bjorn Pettersen wrote:
> > I'm just starting to work with XML, so be gentle <wink>
> >
> > The problem is that I'm reading in a 280K xml file using the sample code
> > from the XML howto:
> >
> > def getXmlDomDocument(name):
> >         p = saxexts.make_parser()
> >         dh = SaxBuilder()
> >         p.setDocumentHandler(dh)
> >         p.parseFile(open(name))
> >         p.close()
> >         doc = dh.document
> >         xml.dom.utils.strip_whitespace(doc)
> >         return doc
> >
> > it takes about five seconds to read and parse the file...
> >
> > Is there a better way to read the file (or is there updated code that is
> > faster)?
> 
> If you want a DOM for the output, then no... you'll have to deal with the
> speed. If you have simple requirements for the Python representation of
> the XML, then take a look at xml.utils.qp_xml.

Hey, that works great! (down to ~0.5 seconds, and it doesn't have
problems with installer either -- life is good ;-)

-- bjorn