title: Get XML data from website inside PHP file (Internal Server Error)
body: <p>I need to get XML data from a website using an API key, and I'm using AJAX and PHP.
  Here's my AJAX code (btw, the PHP file is inside a FileZilla server):</p>
  
  <pre><code>var xmlHttpObj=null;
  var isPostBack=false;
  
  function CreateXmlHttpRequestObject( )
  { 
  
    if (window.XMLHttpRequest)
    {
      xmlHttpObj=new XMLHttpRequest()
    }
    else if (window.ActiveXObject)
    {
      xmlHttpObj=new ActiveXObject("Microsoft.XMLHTTP")
    }
    return xmlHttpObj;
  }
  
  function MakeHTTPCall_Tags()
  {     
  
    var link = "http://phpdev2.dei.isep.ipp.pt/~i110815/recebeXml.php";
    xmlHttpObj = CreateXmlHttpRequestObject();
    xmlHttpObj.open("GET", link, true);
    xmlHttpObj.onreadystatechange = stateHandler_Tags;
    xmlHttpObj.send();
  
  }
  
  function stateHandler_Tags()
  {
    if ( xmlHttpObj.readyState == 4 &amp;&amp; xmlHttpObj.status == 200)
    {       
        var selectTags = document.getElementById("tag");
        var option;
        var docxml = xmlHttpObj.responseXML;
        var nodelist = docxml.getElementById("name");
        alert(nodelist.length);
    }  
  }
  </code></pre>
  
  <p>Here's the PHP code:</p>
  
  <pre><code>&lt;?php
      header("Access-Control-Allow-Origin: * ");
      // pedido ao last.fm com a função file_gets_contents 
      // a string XML devolvida pelo servidor last.fm fica armazenada na variável $respostaXML 
      $respostaXML= 
      file_get_contents("http://ws.audioscrobbler.com/2.0/?method=tag.getTopTags&amp;api_key=4399e62e9929a254f92f5cde4baf8a16"); 
  
      // criar um objecto DOMDocument e inicializá-lo com a string XML recebida 
      $newXML= new DOMDocument('1.0', 'ISO-8859-1'); 
      $newXML-&gt;loadXML($respostaXML); 
      echo $newXML;
  ?&gt;
  </code></pre>
  
  <p>I'm getting this error from the browser console: 
  GET <a href="http://phpdev2.dei.isep.ipp.pt/~i110815/recebeXml.php" rel="nofollow">http://phpdev2.dei.isep.ipp.pt/~i110815/recebeXml.php</a> 500 (Internal Server Error)
  Anybody knows whats wrong?</p>