Hi guys, ok I’m going through this book called “Learning PHP Data Objects”. Just saying so there’s a reference. Anyway I’m getting the following error when I upload the code below. The page is saved as books.xm.php. Can anyone help me?
Thanks
This page contains the following errors:
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.
<?php
/*
* this page lists all of the books we have as an XML data structure
* PDO LibraryManagement example application
* @author Dennis Popel
*/
// don't forget the include
include('common.inc.php');
// set the content type to be XML
header('Content-Type: application/xml');
// get the books list
$books = Model::getBooksWithAuthors();
// echo XML declaration and open rot element
echo '<?xml version="1.0"?>', "\
";
echo "<books>\
";
// now iterate over every book and display it
while($b = $books->fetch()){
?>
<book id="<?=$b->id?>">
<isbn><?=$b->isbn?></isbn>
<title><?=htmlspecialchars($b->title)?></title>
<publisher><?=htmlspecialchars($b->publisher)?></publisher>
<summary><?=htmlspecialchars($b->summary)?></summary>
<author>
<id><?=$b->author?></id>
<lastName><?=$b->lastName?></lastName>
<firstName><?=$b->firstName?></firstName>
</author>
</book>
<?php
} // end while($b = $books->fetch()){} loop
echo '</books>';
?>