O'Reilly logo

XML Parsing with PHP by John M. Stokes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Basic XMLReader & XMLWriter

How It Compares

XMLReader is PHP’s implementation of an XML pull parser.

You may have heard of SAX—the Simple API for XML. PHP 4’s DOMXML bears many characteristics of a SAX implementation: parsing the document as a stream, handling each tag as a callback, and complete lack of awareness about what happens before or after the cursor’s location in the file. We have already discussed the disadvantages of DOMXML in Chapter 1.

SimpleXML and DOM both approach XML parsing from a DOM-based perspective. In other words, they create a representation of the entire document in memory. This makes it easy to jump to random locations in the file and move nodes around but takes a toll on system resources.

StAX is an attempt to split ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required