How can I display the data returned from cURL as an XML document on the page?
Currently I get something like this:
[something] => 189129
[somethingElse] => exampleContent
[somethingElse1] => someMoreExamples
[somethingElse2] => evenMoreExamples
From this code:
$url = "http://example/";
$header[] = 'Accept: application/xml';
$header[] = 'Accept-Encoding: gzip';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$xmlResponse = new SimpleXMLElement($response);
?>
<?php
print_r('<pre>');
print_r($xmlResponse);
print_r('</pre>');
?>
Is there a way to format the response directly as XML or a way to transform it after with php?
Thanks.