craigt Posted July 13, 2015 Share Posted July 13, 2015 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. Quote Link to comment Share on other sites More sharing options...
Solution boompa Posted July 13, 2015 Solution Share Posted July 13, 2015 Try setting the curl option CURLOPT_FOLLOWLOCATION to true. Looks like there's a redirect occurring now. Quote Link to comment Share on other sites More sharing options...
craigt Posted July 14, 2015 Author Share Posted July 14, 2015 (edited) That has worked perfectly; thanks for your help! Edited July 14, 2015 by craigt Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.