0

I'm grabbing some XML from a URL using CURL in PHP

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$base_xml = curl_exec($ch); 
curl_close($ch);

When I view the link in a browser, the XML displays fine and is valid. However when I view the source of the CURL ($base_xml) it is not valid XML as an additional '1' character has been added to the end of the XML so I'm getting a

Extra content at the end of the document in 

error when trying to parse the XML using PHP XMLReader

Why would this be and how can I resolve this?

Thanks in advance

Franco
  • 2,846
  • 7
  • 35
  • 54
  • Duplicate of http://stackoverflow.com/questions/1011003/problem-with-xml-file-saving-using-curl-and-php – Tisho Jul 05 '12 at 07:34

2 Answers2

2
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);//what you need to add.
$base_xml = curl_exec($ch); 
curl_close($ch);
Lake
  • 813
  • 4
  • 6
0

I had a similar issue that I was able to resolve by setting the following option:

curl_setopt($ch, CURLOPT_SSLVERSION, 3);