WordPress RSS Feed XML Parsing ErrorThe other day I encountered “XML Parsing Error: XML or Text Declaration Not at Start of Entity” error when I accessed Globinch blog RSS Feed. Till the previous day everything was OK. Because of this error Globinch Feedburner feed got problems and was not delivering the daily updates to the readers. It took me almost 12 hours to fix this.

Why : XML Parsing Error: XML or Text Declaration Not at Start of Entity

In a well formed XML the XML Prolog (starts with “<?xml … ?>”), if present,  should be the first entry of the file. There should not be any blank line  before the XML Prolog. So if you have a blank line just before the  “<?xml version=”1.0″ encoding=”UTF-8″?>” You will encounter the above error. See the screen shot below.Fix WordPress RSS Feed Error
I searched many blogs and discussion forums. Most of them suggested to check the “wp-includes/feed-*” files for blank lines. I checked all those files and uploaded if necessary. Some blogs suggested to add some scripts which will remove the new line and tab characters from the generated string. I tried all these but the RSS error was still there.

Fix for XML Parsing Error

The question is who or which script file is introducing the blank line in the RSS XML? Unfortunately it is very easy to introduce that bug in PHP. If any of your PHP file (may not be directly related to feed) has a blank line before or after (outside) bracketed sections (<?php and after ?>) causes the issue.

This can introduce the blank line in the feed RSS.

Possible Fixes

1. Using WordPress plug-ins

There is a wordpress Plug-infix-rss-feed” available that can be used to fix the RSS feed.
Download fix-rss-feed plugin from the wordpress repository.

  1. Download the plugin from above download link.
  2. Unzip and upload it to /wp-content/plugins directory.
  3. Change the permission of your all .php files to “777” for time being.This will help the plugin to remove the blank lines from the files if the files are writable.
  4. Go to your dashboard and activate the plugin and follow the instructions to scan the files and to fix the blank lines.
  5. Once the process is over change the permission of all the .php files back to the original (“755”).

I tried this solution, unfortunately in my case this plugin didn’t help me. It did removed many spaces in many .php files but the RSS error was still there.

2. Deactivate your plug-ins one by one

This is the second step I tried. It was suggested in many blogs and forums. I deactivated each plugin and checked and activated them again. But this procedure also did not help me.

3. Check your files manually.The final solution

Finally I tried another approach. I sorted all my .php files which I had changed in the last two days. I found that only one file I changed, It was functions.php in my themes folder. I check for blank lines, there were none. Finally I found that there is a space after one “?> “ php close tag. Removed it and uploaded the file using FTP. Checked the RSS Feed. It was perfect!
So you can try all these options. Find out the PHP files which you changed just before you encountered this error and remove any blank lines or space in that file before .

Sign up for our newsletter to receive great articles!
Placeholder Placeholder
Binu GeorgeWordPress Tipshow-to guides,productivity,RSS Feed Error,RSS XML error,XML Feed error,XML Parsing ErrorThe other day I encountered 'XML Parsing Error: XML or Text Declaration Not at Start of Entity' error when I accessed Globinch blog RSS Feed. Till the previous day everything was OK. Because of this error Globinch Feedburner feed got problems and was not delivering the daily updates to...Tech-Knowledge that helps