Martijn's PHP Coding Blog


November 9th, 2009

PHP5 : SimpleXML Study Notes - 2

XML Summer School by psd @ flickr

XML Summer School by psd @ flickr

Below are some of the notes I made while preparing for the Zend PHP5 exam. They are a quick memory jog of how SimpleXML works and its limitations.

The SimpleXML extension provides easier access to XML files. It is simpler to use but also much more limited than the DOM XML extension. If your document makes use of XML namespaces (ns:foo) then it is better NOT to use SimpleXML as it will become anything but simple.

SimpleXML only supports XML 1.0. If fed an XML 1.1 document it will show “Unsupported version ‘1.1′” warnings, but will continue and attempt to read the file.

Removing elements is not really supported and the opportunities for modification are limited. SimpleXML is best used for straightforward reading and using of XML files. Read the rest of this entry »