Parsing XML with PHP and Expat

There's more to XML than just composing XML documents and DTD files, although that certainly would be sufficient. One thing you can do with XML is parse it. Parsing XML is a matter of using an application or library to access XML files and check to make sure they are well-formed (free of errors) and valid. At the same time, the information can be transformed to suit other purposes. I'll explain all this in better detail.

A parser, in short, takes XML files and breaks them down into their various pieces. As an example, the code <artist>Air</artist> consists of the opening tag (<artist>), the content (Air) and the closing tag (</artist>). While this distinction is obvious to the human eye, it's a great feature of ...

Get PHP Advanced for the World Wide Web: Visual QuickPro Guide 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.