I'm trying to get xml data from link given below and saving it into my mysql db
source:https://www.nestle.com/_handlers/rss.ashx?q=Press_Release
libxml_use_internal_errors(true);
$url="https://www.nestle.com/_handlers/rss.ashx?q=Press_Release";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url); // get the url contents
$data = curl_exec($ch); // execute curl request
curl_close($ch);
$response=simplexml_load_string($data);
if ($response === false) {
echo "Failed loading XML
";
foreach(libxml_get_errors() as $error) {
echo "\t", $error->message;
}
}
error : Failed loading XML Opening and ending tag mismatch: META line 3 and html Premature end of data in tag head line 2 Premature end of data in tag html line 1
I have also tried simplexml_load_file but I am get errors , using php 5.6