Trying to make a dynamic XML Sitemap for Google

When I run this script I made, it produces all the data (URLs, last modified date, etc) but it does not look like a standard XML feed. Is there something I’ve overlooked? I want to make a dynamic Sitemap so that Google always has the full list of all my dynamic content.

Thanks!!


<?php

include 'db.inc.php'; 

print ("<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>");
print ("<urlset xmlns=\\"http://www.sitemaps.org/schemas/sitemap/0.9\\">");


$getTestimonials = "SELECT tID, date from testimonies where approved ='Yes' order by date desc limit 15";

$result = mysql_query ($getTestimonials) OR die(mysql_error());

if ($row = mysql_fetch_array($result)) {

print ("<urlset>\
");

do {

$tID		= $row["tID"];
$date		= $row["date"];	


$date = date("D, d M Y H:i:s \\G\\M\\T");


print ("\
\
<url>\
");
print ("<loc>http://www.oil-testimonials.com/essential-oils/$tID</loc>\
");
print ("<lastmod>$date</lastmod>\
");
print ("<changefreq>yearly</changefreq>\
");
print ("</url>\
");

} while($row = mysql_fetch_array($result));

print ("</urlset>\
");

} else {print "Sorry, no testimonials were found!";}


?> 


I’m not sure what you mean by it doesn’t look like a standard XML feed. Can you post a sample of it?

You should probably have it send Content-type: text/xml headers if it isn’t already. Otherwise it will most likely default to text.

And if you want indentation you could add some "\ "s here and there.