title: PHP XML error - extra content at the end of the document
body: <p>I have the PHP code below, intended to create an XML document from 3 columns and multiple rows in an MySQL database. I am getting the following error message: </p>
  
  <blockquote>
    <p>This page contains the following errors:</p>
    
    <p>error on line 8 at column 11: Extra content at the end of the document
    Below is a rendering of the page up to the first error.</p>
    
    <p><em>-Some correct output as text.-</em></p>
  </blockquote>
  
  <p>It drives me crazy, I have added and removed XML stuff in the code but nothing helps. </p>
  
  <pre><code>&lt;?php
  header('Content-type: text/xml');
  
  $xmlout = "&lt;?xml version=\"1.0\" ?&gt;\n";
  $xmlout .= "&lt;TestXML&gt;\n";
  
  $db = new PDO('mysql:host=localhost;dbname=hidden','hidden','hidden');
  $stmt = $db-&gt;prepare("SELECT * FROM testDB");
  $stmt-&gt;execute();
  while($row = $stmt-&gt;fetch()){
   $xmlout .= "\t&lt;test&gt;\n";
   $xmlout .= "\t\t&lt;one&gt;".$row['one']."&lt;/one&gt;\n";
   $xmlout .= "\t\t&lt;two&gt;".$row['two']."&lt;/two&gt;\n";
   $xmlout .= "\t\t&lt;three&gt;".$row['date1']."&lt;/three&gt;\n";
   $xmlout .= "\t&lt;/test&gt;\n";
  }
  
  $xmlout .= "&lt;/TestXML&gt;";
  echo $xmlout;
  ?&gt;﻿
  </code></pre>
  
  <p>Help is very appreciated!</p>