I have this code:
<?php
header('Content-type: text/xml');
$xmlout = "<?xml version=\"1.0\" ?>\n";
$xmlout .= "<persons>\n";
$db = new PDO('mysql:host=localhost;dbname=xxx','root','');
$stmt = $db->prepare("select * from users");
$stmt->execute();
while($row = $stmt->fetch()){
$xmlout .= "\t<person>\n";
$xmlout .= "\t\t<id>".$row['id']."</id>\n";
$xmlout .= "\t\t<username>".$row['username']."</username>\n";
$xmlout .= "\t\t<password>".$row['password']."</password>\n";
$xmlout .= "\t\t<realname>".$row['realname']."</realname>\n";
$xmlout .= "\t\t<surname>".$row['surname']."</surname>\n";
$xmlout .= "\t\t<email>".$row['email']."</email>\n";
$xmlout .= "\t\t<created>".$row['created']."</created>\n";
$xmlout .= "\t\t<admin>".$row['admin']."</admin>\n";
$xmlout .= "\t</person>\n";
}
$xmlout .= "</persons>";
echo $xmlout;
?>
and it doesn't work, it have this error:
error on line 2 at column 1: Extra content at the end of the document Below is a rendering of the page up to the first error.
Does anybody know, where is problem?