Header sample.gif

When performing string comparisons, you should note that SimpleXMLElements are of type "Object." In order to perform a proper string comparison, you must first cast the SimpleXMLElement using "(String)". Some sample code is shown below:

<?php    
include 'example.php';

$xml = new SimpleXMLElement($xmlstr);

if ((string) $xml->movie->title == 'PHP: Behind the Parser') {
    print 'My favorite movie.';
}

htmlentities((string) $xml->movie->title);
?>