Hi James,
The problem is caused by a blank in one of the PHP files of your theme. You need to check all the files of your theme to look for a blank line before the opening PHP tag or after the closing PHP tag. Once you delete that the sitemap should work fine and Google should accept it.
Thanks very much for your quick response. I don’t suppose you would know a quick way to find out which file the problem is in ?
Thanks, James.
I have just enabled sitemap indexing and it looks like it may have sorted it. Can you have a look and let me know if it has. Sorry to be a pain, i am new to this.
https://jamesdicksonbooks.com/sitemap.xml
Thanks again for your help.
Hi James,
I wouldn’t enable sitemap indexes if I were you. Google seems to have a problem with them and I’ve seen a lot of people report issues with Google when doing this. Sitemap indexes should only be used when you have over 50,000 URLs on your XML Sitemap.
I don’t know a quick and easy way to find blank lines in a PHP file. Its a known issue with XML that if you have a blank line outside PHP tags then XML will break. If you search Google you’ll see many results for this and many people asking if there’s an easy way to find blank lines. Some people have posted solutions that use egrep and other advanced Linux commands but you’d have to be very good with Linux to do this. My advise, start with the functions.php file, then the header.php file, then the footer.php file.
I do see that you are caching your XML Sitemap using WP Super Cache. This is an extremely bad idea because then Google could get a cached sitemap and not the latest sitemap. You need to consult the documentation or support for WP Super Cache on how to exclude the XML Sitemap from caching.
Hi,
i think it has sorted it self out now. I disabled sitemap indexing and it seems to be accessible now. Can you check it when you get a minute just to be safe. https://jamesdicksonbooks.com/sitemap.xml
Thanks for your help, James.
Hi James,
I’m still seeing the original problem which is caused by a blank line in a PHP file –
error on line 2 at column 1: Extra content at the end of the document
The best way to resolve this is to find that blank line. Check the main theme files – functions.php, header.php, footer.php, index.php, page.php and single.php first.