title: Unable to export XML from PHP using WAMPServer
body: <p>I am using WAMPServer 2.1 on my local machine. I am trying to create a simple PHP script to output an XML file.  I cannot get it to work without generating an error on IE and Chrome.  On Firefox 4, it works.</p>
  
  <p>Here is the PHP:</p>
  
  <pre><code>&lt;?php
  
  main();
  
  function main()
  {
      header("Content-type: application/xml");
      OutputXML('xml/login_user_good.xml');
      exit(0);
  }
  
  function OutputXML($filename)
  {
      echo file_get_contents($filename);
  }
  
  ?&gt;
  </code></pre>
  
  <p>Here is the XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;login_user&gt;
      &lt;result_code value="1"/&gt;
      &lt;error value="Invalid username or password"/&gt;
  &lt;/login_user&gt;
  </code></pre>
  
  <p>When I tried to access my PHP script using IE 8, I get this error:</p>
  
  <pre><code>The XML page cannot be displayed  Cannot view XML input using style sheet.
  Please correct the error and then click the Refresh button, or try again later. 
  --------------------------------------------------------------------------------
  Invalid at the top level of the document. Error processing resource
  'http://localhost/kiamobile/login_user.php'. Line 1, P...
  
  &lt;?xml version="1.0" encoding="utf-8" ?&gt; 
  ^
  </code></pre>
  
  <p>On Google Chrome 10, I get this error:</p>
  
  <pre><code>This page contains the following errors:
  
  error on line 1 at column 6: XML declaration allowed only at the start of the document
  </code></pre>
  
  <p>On Firefox 4, I get a properly formatted XML output.</p>
  
  <p>On any of the browsers, when I View Source, I can see the correct XML.</p>
  
  <p>I have tried with and without the explicit header.  If I remove the call to the PHP header() function, I get these results:</p>
  
  <ul>
  <li>IE 8: Same error as before </li>
  <li>Firefox 4: Blank screen</li>
  <li>Chrome 10: Blank screen</li>
  </ul>
  
  <p>Again, if I View Source in any of the browsers, I can see the XML. I have tried using text/html instead of application/xml, with no effect.</p>
  
  <p>I have tried generating the XML directly in the PHP code, like this:</p>
  
  <pre><code>&lt;?php
  
  main();
  
  function main()
  {
      header("Content-type: application/xml");
      OutputXML();
      exit(0);
  }
  
  function OutputXML()
  {
  echo &lt;&lt;&lt;END
  &lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;login_user&gt;
      &lt;result_code value="1"/&gt;
      &lt;error value="Invalid username or password"/&gt;
  &lt;/login_user&gt;
  END;
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>When I do this, I get these results:</p>
  
  <ul>
  <li>IE 8: Same error</li>
  <li>Firefox 4: I see the formatted XML</li>
  <li>Chrome 10: Blank screen</li>
  </ul>
  
  <p>What am I doing wrong?</p>