Jump to content

PHP XML Import script error - simplexml_load_string and xpath


craigt
Go to solution Solved by boompa,

Recommended Posts

I have a XML import script which uses "simplexml_load_string" to import a Feed of real estate properties. The script is scheduled to run 1am each night. 

 

It has worked fine for many months; but yesterday it started to error with the below:

 

PHP Warning:  simplexml_load_string() [<a href='function.simplexml-load-string'>function.simplexml-load-string</a>]:

Entity: line 2: parser error : Extra content at the end of the document in /public_html/import/import-script.php on line 26

 

PHP Warning:  simplexml_load_string() [<a href='function.simplexml-load-string'>function.simplexml-load-string</a>]: <body><h1>Object Moved</h1>This object may be found <a HREF="http://admin.homees in /public_html/import/import-script.php on line 26

 

PHP Warning:  simplexml_load_string() [<a href='function.simplexml-load-string'>function.simplexml-load-string</a>]: ^ in /public_html/import/import-script.php on line 26

 

PHP Fatal error:  Call to a member function xpath() on a non-object in /public_html/import/import-script.php on line 28

Status: 500 Internal Server Error

X-Powered-By: PHP/5.2.17

Content-type: text/html

 

I cannot understand why this error shows; as the feed still opens in a browser all ok. Plus W3C validate it as all ok too.

 

Please can anyone explain what this error means / why I might be seeing it? 

 

Also I check the Server Log and it says:

[error] [client 46.208.46.63:41713] AH01215: PHP Fatal error:  Call to a member function xpath() on a non-object in /public_html/import/import-script.php on line 30

 

This is a snippet of our PHP import script: 

 

$ch2 = curl_init();
$timeout = 60; 
curl_setopt ($ch2, CURLOPT_URL, "external-website/provided-feed.xml");
curl_setopt ($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch2, CURLOPT_CONNECTTIMEOUT, $timeout);
$xmlstring = curl_exec($ch2);
curl_close($ch2); 
    
$xml = simplexml_load_string($xmlstring);
$propertys = $xml->xpath("//property");
$count=0;
 
Huge thanks in advance! Craig.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.