I am new to programming and am having trouble trying to render mysql query results in xml format using php. I have looked over my code several time and tried several things but I get a message saying "error on line 2 at column 1: Extra content at the end of the document" in my browser. I have the code below:
<?php
header ("content-type: text/xml");
include("database.php");
$xml='<?xml version="1.0" encoding="UTF-8"?>';
$res=$pdo->query('SELECT * FROM sk_courses ORDER BY courseID ASC');;
$xml.='<courses>';
while ($result=$res->fetch(PDO::FETCH_ASSOC)){
$xml.='<course>
<courseID>'.$res['courseID'].'</courseID>
<courseName>'.$res['courseName'].'</courseName>
</course>';
}
$xml.='</courses>';
echo $xml;
?>