O'Reilly logo

PHP 5 CMS Framework Development by Martin Brampton

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

Framework solution

The following sections cover practical implementation details for the topics discussed previously. Again, there is no particular link between the sections.

Reading XML files easily

The hard work of parsing the XML will be done by SimpleXML, available by default with PHP5. We can wrap it up in a way that makes it easier to use, especially in relation to handling error conditions of various kinds. The basic code that gets the aliroXML class going is as follows:

class aliroXML { protected $xmlobject = null; protected $maintag = ''; protected $valid = true; public function loadFile ($xmlfile, $attribs=0) { if (!file_exists($xmlfile)) throw new aliroXMLException(sprintf(T_('Requested XML file %s does not exist'), $xmlfile)); ...

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