As the title says, I've been trying to wrap my head around this error for the past couple of hours. I can't seem to find anything wrong with the code and I have compared it to several other examples that reportedly work.
Here is my code:
$q_export= $pdo->query("SELECT * FROM Produse");
$string="<produs><br />";
while($results_exp= $q_export->fetch(PDO::FETCH_ASSOC))
{
$IDexp=$results_exp['ID'];
$DenExp=$results_exp['Denumire'];
$DescrExp=$results_exp['Descriere'];
$PretEx=$results_exp['Pret'];
$string .= "<ID>".$IDexp."</ID>"."<br />";
$string .= "<Denumire>".$DenExp."</Denumire>"."<br />";
$string .="<Descriere>".$DescrExp."</Descriere>"."<br />";
$string .="<Pret>".$PretEx."</Pret>"."<br />";
}
$string .="</produs>";
$xml_export= new SimpleXMLElement($string);
Header('Content-type:text/xml');
echo $xml_export->asXML();
And the error it gives is:
This page contains the following errors:
error on line 9 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.
I'd greatly appreciate any input! :)