title: PHP - problems getting XML using simplexml_load_file
body: <p>I'm having trouble getting the XML from a file using the simplexml_load_file function. I have tried googling, but everyone else seems to have problems when they get an actual error or warning. I get no error and no warnings, but when I do this:</p>
  
  <pre><code>$sims = simplexml_load_file("http://my-url.com/xml.php") or die("Unable to load XML file!");
  var_dump($sims);
  </code></pre>
  
  <p>the output is:</p>
  
  <pre><code>object(SimpleXMLElement)#1 (1) {
    [0]=&gt;
    string(1) "
  "
  }
  </code></pre>
  
  <p><br /><br />However, if I do this:</p>
  
  <pre><code>$ch = curl_init("http://my-url.com/xml.php");
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $output = curl_exec($ch);
  curl_close($ch);
  echo $output;
  </code></pre>
  
  <p>the output is:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;simulators&gt;
      &lt;simulator&gt;
          &lt;mac&gt;00-1A-4D-93-27-EC&lt;/mac&gt;
          &lt;friendlyName&gt;a Travis Desk&lt;/friendlyName&gt;
          &lt;roundSessions&gt;2&lt;/roundSessions&gt;
          &lt;rangeSessions&gt;0&lt;/rangeSessions&gt;
          &lt;timePlayed&gt;00:03:21&lt;/timePlayed&gt;
      &lt;/simulator&gt;
  &lt;/simulators&gt;
  </code></pre>
  
  <p><br /><br />I have gotten it to work by doing this:</p>
  
  <pre><code>$ch = curl_init("http://my-url.com/xml.php");
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $output = curl_exec($ch);
  curl_close($ch);
  
  $sims = simplexml_load_string($output) or die("Unable to load XML file!");
  var_dump($sims);
  </code></pre>
  
  <p>which outputs:</p>
  
  <pre><code>object(SimpleXMLElement)#1 (1) {
    ["simulator"]=&gt;
    object(SimpleXMLElement)#2 (5) {
      ["mac"]=&gt;
      string(17) "00-1A-4D-93-27-EC"
      ["friendlyName"]=&gt;
      string(13) "a Travis Desk"
      ["roundSessions"]=&gt;
      string(1) "2"
      ["rangeSessions"]=&gt;
      string(1) "0"
      ["timePlayed"]=&gt;
      string(8) "00:03:21"
    }
  }
  </code></pre>
  
  <p>I'm just wondering why the first method didn't work? I have PHP Version 5.3.2-1ubuntu4.5 and libxml Version 2.7.6 running on Ubuntu Server 10.04.</p>
  
  <p>Thanks!</p>
  
  <p>-Travis</p>