PHP and SAX
PHP 4.0 comes with a very capable SAX parser based on the expat library. Created by James Clark, the expat library is a fast, robust SAX implementation that provides XML parsing capabilities to a number of open-source projects, including the Mozilla browser (http://www.mozilla.org/).
If you’re using a stock PHP binary, it’s quite likely that you’ll need to recompile PHP to add support for this library to your PHP build. Detailed instructions for accomplishing this are available in Appendix A, “Recompiling PHP to Add XML Support.”
A Simple Example
You can do a number of complex things with a SAX parser; however, I’ll begin with something simple to illustrate just how it all fits together. Let’s go back to the previous XML document ...
Get XML and PHP now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.