在cURL请求上强制XML输出

I am using a cURL request to get XML data, which works fine in the brower but returns text in the PHP cURL. I have looked at several similar questions here and tried the answers, with no luck. Here's the code.

$url = 'http://forecast.weather.gov/MapClick.phplat=38.4247341&lon=-86.9624086&FcstType=xml';
$agent = 'Myapp/v1.0 (http://example.org;webmaster@example.org)';

$rCURL = curl_init();

curl_setopt($rCURL, CURLOPT_URL, $url);
curl_setopt($rCURL, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($rCURL, CURLOPT_USERAGENT, $agent);
curl_setopt($rCURL, CURLOPT_HTTPHEADER, 'Content-Type: application/xml');
curl_setopt($rCURL, CURLOPT_BINARYTRANSFER, 1);

$aData = curl_exec($rCURL);
$error = curl_error($CURL);

curl_close($rCURL);

if ($error)
echo ($error);
else echo ($aData);

Your request already contains FcstType parameter to specify that response should be returned in XML format: FcstType=xml

Once XML response (string) is returned it could be parsed with SimpleXMLElement class as demonstrated below:

$url = 'http://forecast.weather.gov/MapClick.php?lat=38.4247341&lon=-86.9624086&FcstType=xml';
$agent = 'Myapp/v1.0 (http://example.org;webmaster@example.org)';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

$xml = new SimpleXMLElement($response);
foreach($xml->period as $period){
    echo $period->text . "
";
}