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 DOM

Parsing with DOM

SimpleXML, in keeping with its theme of simplicity, has all its methods contained in a single class. Not so with DOM. DOM is a class hierarchy that represents XML documents, nodes, elements, and attributes with separate classes, as you can see in Figure 5.1. Many of the classes inherit from DOMNode, so you’ll see several references to that class throughout the chapter. For now, let’s start at the beginning: how does an XML document become a DOMDocument object?

Figure 5.1: DOM Class Hierarchy
Figure 5.1: DOM Class Hierarchy

Loading XML

Like SimpleXML, DOM is nearly completely object oriented. Unlike SimpleXML, however, there are no stand-alone functions ...

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