10 tips for PHP scripts: Use XML with PHP

PHP's XML-related functions allow you to create a parser to handle valid XML documents. See how to use XML with PHP.

By Julie Meloni

PHP contains an optional XML extension that supports the Expat parser. The XML-related functions in PHP let you create a parser to handle valid XML documents. If you are using a version of Apache later than 1.3.7, you don't need any additional libraries. All you need to do is configure PHP —with-xml.

There are several good examples of creating a PHP-based XML parser in the PHP Manual. Additionally, the New Riders book Web Application Development with PHP 4.0 includes a good overview of using XML with PHP, and one of the authors of that book has also written a great tutorial at

Just as with Java and COM support, XML support in PHP is in its infancy but growing rapidly. If you have experience with Expat or LibXML, please jump in and lend your expertise.

Julie Meloni is the technical director at i2i Interactive and is an avowed proponent of Linux and the open source community. A regular contribtor to CNET, she has written a few books on PHP and other technologies.

Editor's Picks

Free Newsletters, In your Inbox