Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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.

Here is a pic of the error

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 ............
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
    
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
    
Got it! Thanks a bunch, dude. –  Lance Mar 20 '13 at 3:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.