title: PHP cURL HTTP GET XML Format
body: <p>I have an application that has a Web Services RESTful API. When I make HTTP GET requests in the browser I get XML responses back.</p>
  
  <p>When I make the same request using PHP I get the correct information but it is not formatted in XML and so I can't pass it to Simple XML.</p>
  
  <p>Here's my code.</p>
  
  <pre><code>&lt;?php
  //Deifne user credentials to use with requests
          $user = "user";
          $passwd = "user";
  
          //Define header array for cURL requestes
          $header = array('Contect-Type:application/xml', 'Accept:application/xml');
  
          //Define base URL
          $url = 'http://192.168.0.100:8080/root/restful/';
  
          //Define http request nouns
          $ls = $url . "landscapes";
  
          //Initialise cURL object
          $ch = curl_init();
  
          //Set cURL options
          curl_setopt_array($ch, array(
              CURLOPT_HTTPHEADER =&gt; $header, //Set http header options
              CURLOPT_URL =&gt; $ls, //URL sent as part of the request
              CURLOPT_HTTPAUTH =&gt; CURLAUTH_BASIC, //Set Authentication to BASIC
              CURLOPT_USERPWD =&gt; $user . ":" . $passwd, //Set username and password options
              CURLOPT_HTTPGET =&gt; TRUE //Set cURL to GET method
          ));
  
          //Define variable to hold the returned data from the cURL request
          $data = curl_exec($ch);
  
          //Close cURL connection
          curl_close($ch);
  
          //Print results
          print_r($data);
  
  ?&gt;
  </code></pre>
  
  <p>Any thoughts or suggestions would be really helpful.</p>
  
  <p>S</p>
  
  <p>EDIT:</p>
  
  <p>So this is the response I get from the PHP code:</p>
  
  <pre><code>0x100000rhel-mlsptrue9.2.3.0101
  </code></pre>
  
  <p>This is the response if I use the WizTools Rest Client or a browser.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-16"?&gt;
  &lt;landscape-response total-landscapes="1" xmlns="http://www.url.com/root/restful/schema/response"&gt;
      &lt;landscape&gt;
          &lt;id&gt;0x100000&lt;/id&gt;
          &lt;name&gt;rhel-mlsp&lt;/name&gt;
          &lt;isPrimary&gt;true&lt;/isPrimary&gt;
          &lt;version&gt;9.2.3.010&lt;/version&gt;
      &lt;/landscape&gt;
  &lt;/landscape-response&gt;
  </code></pre>
  
  <p>As you can see the information is there but the PHP is not really presenting this in a useful way.</p>