Re: [PHP-XML-DEV] XMLReader vs. SAX

[email protected] ("Rob Richards") Thu, 30 Sep 2004 11:08:23 -0400
Newsgroups php.xml.dev
Message-ID <[email protected]>
To also answer the question from previous email.

There is no rewind functionality. You will need to use $reader->XML(...)
again. Calling close() is optional. Its current functionality will close and
free the internal resources (just as calling ->XML() will do if needed) as
there is a bug in libxml up to and including 2.6.8 in xmlTextReaderClose()
so the internal functionality was left as is for now.

From: "Vivian Steller

> - first, is XMLReader more "lightweight" than SAX meaning less powerfull?
in
> fact it is simpler.

Its not less powerful, just easier to use.

> - is XMLReader faster than SAX, especially if you want to create a DOM
> structure with SAX-callbackfuncs or with XMLReader->expand()?

xmlReader is faster at least in PHP. Building a DOMDocument object may be
possible in future releases, something I've looked at but havent worked on
yet since it requires libxml 2.6.x.
http://blog.bitflux.ch/archive/processing_large_xml_documents_with_php.html
http://blog.bitflux.ch/archive/processing_large_xml_documents_with_php_5_update.html

> - isn't it possible to programm an "xmlreader" with SAX? would this be
> better/faster than XMLReader extension? SAX: can you stop the processing
> procedure while xml parsing?

If you try to do it in PHP using the xml extension it it would be even
slower than the comparisons are now.

Rob