RSS feed issues solution

My RSS feed came down with a problem recently and began returning the following xml error:

“XML parsing error: :1:1: xml declaration not at start of external entity”

How do you deal with this? This blog gives a short tutorial on how to proceed to fix it.

While the cause of the problem is straightforward it is a tricky one to solve because it can involve a search for the veritable “needle in the haystack”. The problem arises because there is a blank line (or space) either before or after the declarations in php in one of your templates. It seems to be a common problem and arises from not being careful when editing a file to clean out all blank lines – most likely at the end of the file (that is, outside the closing ?> php tag) – and brought about, for example, by just hitting the enter key once.

If the problem has just arisen then it might be a template you edited in the last 24 hours. If you have access to your shell (in linux) then type the following to see which templates you have edited

find . -mtime -1 -name \*.php

This command will return a list of relevant files and if it does then you can check them individually for the problem.

If that doesn’t help (perhaps because the problem is more than a day old) and you cannot remember which files you have been editing then it is a fair bet that it will be in one of the configuration templates (if you are using WordPress templates) – wp-rss.php, wp-atom.php, wp-config.php or in one of the theme templates (very likely the functions.php file).

Go to the excellent RSS Feed validator – http://feedvalidator.org/ to run a diagnostic which gives some clue.

In my case I had edited the functions file in the theme I built (billy_blue) and at the end of the file was a blank line. Fixed with a minimum of fuss. But this can be a taxing problem if you have been doing a lot of editing to build or change a site.

Hope this helps people in a similar situation zero in on the problem.

best wishes
bill

Spread the word ...
    This entry was posted in Admin, Linux. Bookmark the permalink.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    *
    To prove you're a person (not a spam script), type the answer to the math equation shown in the picture.
    Anti-spam equation