SimpleXML

Using SimpleXML with HTML

PHP 5's SimpleXML module is one of the the biggest reasons to upgrade to 5. If you're parsing RSS feeds or the results of webservice requests it works beautifully and saves a ton of time. The only problem with it is that it'll only load valid XML. I banged my head against it for way to long before coming up with the following:

<?php
  $doc
= new DOMDocument();
 
$doc->strictErrorChecking = FALSE;
 
$doc->loadHTML($html);
 
$xml = simplexml_import_dom($doc);
?>

Enabling PHP Modules

Phlickr uses two several of PHP5's extensions, CURL and SimpleXML. In some cases these two extensions may not be enabled by default.

The first step is verify that the modules are not already being loaded. You view a list of the modules using the following command:

for you, a photo

ted

FreeTheAirwaves.com

User login

Syndicate content