# Google's webmaster tools saying invalid URL in sitemap

I've recently made some big changes to my site and as a result, have had to change my sitemap. In doing so, I resubmitted my sitemap file only to see 3 errors reading invalid URL's. I'm not sure if it's worth mentioning or not that my sitemap file ins't actually a true XML file. Rather, it's a dynamic php file that the server is tricked into believing is an XML file thanks to modrewrite. This didn't matter last time as I had no sitemap errors. But, this time it is.

The actual sitemap can be found here

The sitemap.php file starts like this:

<?php
require_once("model/functions.php");
require_once("model/model.php");
require_once("model/teams_array.php");

echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.sportannica.com/quickpicks/</loc>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
Continued ............


I see the following problems:

• Your server return the wrong content type for the sitemap. It returns Content-Type: text/html when it should return Content-Type: application/xml
• Your XML sitemap starts with a new line character. This makes the XML document invalid. When I run it through xmllint I get the following error: sitemap.xml:2: parser error : XML declaration allowed only at the start of the document

I doubt that the wrong content type is throwing Google off, but it is probably worth fixing.

The new line at the beginning of the document should be fixed. If you are serving it via PHP it could be caused by PHP header information that you have in the document that doesn't get printed. Once I remove the new line at the beginning, xmllint does not report any more problems.

• I posted the beginning of the sitemap file in the hopes that it'll clear things up in regards to the error on line 2. – Lance Mar 19 '13 at 20:04
• It is likely that one of the libraries in the require_once directives is causing the new-line to be printed. I have seen extra new lines at the end of the file after the ?> that cause the problem. – Stephen Ostermiller Mar 19 '13 at 20:09
• Unfortunately, the internet that I have at school wont let me connect to my remote server via ftp to overwrite the sitemap file. So, I won't be able to find out if the new file is valid using google's webmaster tools. But, as soon as I get home tonight I'll let you know how your advice has worked out. Thanks a bunch. – Lance Mar 19 '13 at 20:12
• I think the problem is with the files that are being required. What could it be in those files that's throwing an error? Could it be comment tags? – Lance Mar 20 '13 at 3:10