I want to show my database in XML if the API-key is correctly. Everything works fine until the XML page should show up. It shows this error:
This page contains the following errors:
error on line 3 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.
My code:
$sql = "SELECT * FROM WKplayers";
$res = mysqli_query($con, $sql);
$xml = new XMLWriter();
$xml->openURI("php://output");
$xml->startDocument();
$xml->setIndent(true);
$xml->startElement('Players');
while ($row = mysqli_fetch_assoc($con, $res)) {
$xml->startElement("Player");
$xml->writeRaw($row['Player']);
$xml->endElement();
}
$xml->endElement();
header('Content-type: text/xml');
$xml->flush();
No comments:
Post a Comment