convert 5.1.2 code php to 5.0.4

I've been doing research on why my code is not working and it seems, and please correct me if I am wrong, it is due to this part  

$xml = new SimpleXMLElement($xml_request_url, null, true);

it appears SimpleXML is not supported in 5.0.4, needs to 5.1.x, I cannot change the PHP version on the server, is it possible to convert this code so it will work with 5.0.4.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">

        <form name='frmTest' method='post' action='<?php echo $_SERVER['PHP_SELF'];?>'>
              <input type='text' name='txtSearch'/>
              <input type='submit' value='Search'/>
      if (isset($_POST["txtSearch"])) {
        $user_name = 'UserName';
        $secret_key = 'gfjuhchj';
        $search_phrase = $_POST["txtSearch"];
        $query_hash = md5($secret_key.$search_phrase);
        $xml_request_url = ''.$user_name.'/'.$query_hash.'/'.urlencode($search_phrase);
        $xml = new SimpleXMLElement($xml_request_url, null, true);
        if (isset($xml->err)) {
          echo $xml->err['msg'];
        } else {
        print "<table>";
          foreach ($xml as $title) {
           echo  "<tr><td><h3>'Title: '</h3>".$title->name."</td></tr><br />";
            echo "<tr><h3>'Category: ''</h3>".$title->category.': '.$title->subcategory."<br />";
            echo "<a href='Image: '><img src=".$title->image."/></a> <br /> ";     
            foreach ($title->covers->cover as $cover) {
                       echo "<h3>'Average rating:''</h3>".$cover->average_rating."<br />";

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Any version of PHP5 supports SimpleXMLElement as far as I'm aware. Only certain elements of the class require a higher version, but your script should not be affected unless you want to start manipulating it by e.g. adding elements.

One possibility is that you do not have allow_url_fopen set to On. You can change this in your php.ini file. If you have shared hosting, you'll likely need to ask your provider to change it, there is no other way around that as far as I know.

A simple test will show if it is enabled. Create a new file with the following contents:

$test = file_get_contents("");
echo $test;

If you see the google homepage, then the problem is not that!
If you can get the contents of the page via what rjdown suggested. Try throwing the contents into simplexml like this:

$xml = simplexml_load_string($string);
print_r( $xml );

SimpleXML is 5.0+
Has rjdown's solution worked for you?

Otherwise could you give the full error message you receive?
CiscoTavonAuthor Commented:
rjdown I see the Google page.

the error message is

Fatal error: Uncaught exception 'Exception' with message 'SimpleXMLElement::__construct() expects exactly 1 parameter, 3 given' in /home/07009321/public_html/b1.php:23 Stack trace: #0 /home/07009321/public_html/b1.php(23): SimpleXMLElement->__construct('http://www.allc...', NULL, true) #1 {main} thrown in /home/07009321/public_html/b1.php on line 23
could you try changing line

$xml = new SimpleXMLElement($xml_request_url, null, true);


$xml = simplexml_load_file($xml_request_url);

and see what you get?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.