O'Reilly logo

Mastering PHP 7 by Branko Ajzele

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

XML extensions

There are several ways to read and write XML documents in PHP, including regular expressions and specialized classes and methods. The regex approach is error-prone, especially with complex XML documents, which is why the use of extensions is advised. PHP provides several extensions for this purpose, the most common ones being as follows:

  • XMLWriter: This allows us to generate streams or files of XML data
  • XMLReader: This allows to read the XML data 
  • SimpleXML: This converts XML to an object and allows for an object to be processed with normal property selectors and array iterators
  • DOM: This allows us to operate on XML documents through the DOM API

The basics of dealing with an XML document are about proper reading and writing ...

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