Skip to main content
Published: May 17 2007, 3:25:00 PMUpdated: August 23 2022, 1:56:39 AM

XML parser support is much better in PHP 5 relative to PHP 4. PHP 5’s Simple XML extension is a very good basic XML parser.


PHP 4

XML parser support in PHP 4 was limited. The default installation included a SAX parser. A DOM parser could be enabled (uncomment extension=extensions\php_domxml.dll in php.ini in Windows) but the DOM parser was unstable.


PHP 5

PHP 5 supports several XML parsers including the following :

ext/simplexml
- modeled after Perl’s XML:Simple
- easy object-oriented XML parsing, with some limitations relative to other parsers
- random access to any element in XML object

ext/xml
- SAX2 event-based parsing
- backwards compatible with PHP 4 parser

ext/dom
- object-oriented navigation, creation and modification of XML documents

ext/xmlreader
- stream-oriented XML parsing
- based upon Microsoft’s System.Xml.XmlReader
- no random access to XML tree – forward-only parsing

PHP 4 or 5

The following parsers are written in PHP, so are therefore slower than most of the compiled XML parsers mentioned above. They generally are compatible with PHP 4 or 5.

PEAR:XML_Parser – a SAX-based parser.

PEAR:XML_Tree – a DOM-based parser that arose because a DOM-based parser was not in default PHP 4 installations.


Additional resources

PHP 4

DOMXML


PHP 5

SimpleXML

SAX

XMLReader

DOM

How well did this answer your question?
Answers others found helpful