XML Parser Functions
In this section, we will examine PHP’s event-based XML parser functions. Prior to PHP 5, these were based on Jim Clarke’s Expat library (XML Parser Toolkit), which is available from http://www.jclark.com/xml/expat.html. As of PHP 5, all PHP’s XML functions use libxml2 (http://www.xmlsoft.org/). Event-based models for parsing XML are not the easiest to use, but they can be very efficient. Handler functions are invoked as XML elements are encountered, whereas alternatives such as DOM require that entire documents are modeled in memory before you work with them.
Acquiring a Parser Resource
To begin parsing a document, you need a parser resource. You can acquire one of these with the xml_parser_create() function. xml_parser_create() ...
Get Sams Teach Yourself PHP in 24 Hours, Third Edition 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.