In a new link from Dynamically Typed today, Harry points out some "interesting thoughts" about PHP 5 and XML parsing.
In a link to Christian's weblog, he points out some of the differences between parsing a 10Mb XML document with PHP 5's new XML APIs - as well as the memory requirements for each (DOM vs. Sax / XMLReader).
Personally a little surprised that XMLReader proved faster than SAX. "Pull style" XML parsers are usually implemented by "re-routing" a SAX parser and from a quick glance at the libxml2 source, it seems to do the same. I guess executing alot of callback functions at a C level is faster than executing them up at the PHP level.
And, if you want further proof that the new changes to the XMLReader API helped: also checked with a 100MB Document. With DOM it took 38 sec of user time and 256MB of memory, with "XMLReader next", it took 16 sec and memory usage was still at 3.2 MB.




