Fix WordPress Feed XML Parsing Errors: Delete Blank Lines

Our Feedburner feed was down, and so was the WordPress source feed which showed “XML Parsing Error: XML or text declaration not at start of entity“. And all this while Google reader was correctly tracking our feed, while it was not loading in any web browser!

XML Parsing Error

Firefox showed this error on loading the feed
XML Parsing Error

XML Parsing Error: XML or text declaration not at start of entity Location: Line Number 2, Column 1: ^

Google Chrome revealed some more information
chrome XML Parsing Error

This page contains the following errors: error on line 2 at column 6: XML declaration allowed only at the start of the document Below is a rendering of the page up to the first error.

I searched around various forums and blogs for possible causes and found that it was most commonly caused by a Blank line before XML declaration

Basically this error arises if there is a whitespace before an XML declaration (<?xml ... ?>) appears in your feed. The blank line error means that the code has blank lines in it, which can be easily introduced in the WordPress php code by a plugin, theme, or any configuration file.

So basically I had to go looking for blank lines before PHP starting tag
and after the PHP closing tag

Fixing Blank Line PHP Errors

1. First I deactivated plugins one by one to see if any of them had a coding error. But none of the plugins seemed to cause the error and I activated them all back.

2. Then I logged in via FTP and started checking the wordpress core files. I found that surprisingly many PHP files had blank lines after the closing tag like in wp-config.php in root folder, feed.php in wp-includes to name a few. I downloaded the latest WP2.7.1 version to check if the last autoupdate from WP 2.7 to WP2.7.1 had brought in these blank lines. In fact, the latest WP 2.7.1 version also contains blank lines at end of wp-config-sample.php and feed.php. So I removed the blank lines.

php blank line

3. Then I suspected that I recently altered PHP in my theme configuration files to separate comments and trackbacks. So I checked all my template files, and there it was, a blank line at the end of functions.php. (which was edited earlier to set right the comments count). I deleted the blank line and saved the template.

theme blank line

I suspect that the blank lines in the theme functions.php could be the cause since it was recently changed, but the wordpress core files blank lines could also have caused it. Anyways after deleting all these blank lines, the feed started working instantly and the errors disappeared.

4. Remember to turn off caching by WordPress caching plugins like Wp-cache or WP-supercache, so that you may catch the exact cause of the error.

5. Had this also not worked, I intended to use the ‘Fix RSS Feed WordPress plugin’ which promised to search all folders (except wp-admin and wp-includes directory) if the php file has blank lines in the head and tail line, and then delete blank lines. The plugin author writes that it will delete php files at only the beginning and end of the blank lines, and will not delete the blank lines between documents, so it will not affect the operation of the php programs.

6. Then my Feedburner feed was not updated. So I pinged our feed to Feedburner, but the feed would not update. Then I logged into my Feedburner account > Troubleshooting > Resync Feed. And the Feedburner feed started working instantly.

NOTE: While all feeds were not working in web browsers, surprisingly modern day feed readers are so smart, they can override this error and grab the article correctly. I confirm that I continued to read my latest articles in Google reader and would have never suspected any feed error had a friend not informed me.

Lessons Learnt: Check your feeds regularly and take care of the blank lines when editing PHP files.


  1. Alpesh Nakar says:

    Looks I have been hit too! Will check out tonite. I did customise my theme a lot lately with conditionally tagging in WP and I think this could have caused.

    Thanks for writing this up.

    I was clueless about this :) but did remember you writing about this.

  2. Alpesh Nakar says:

    Update: Yes it was the functions.php that was the culprit.

    Thanks heaps!!!

  3. Kamil Molendys says:

    Thank you very much… It works!

  4. Dadony says:

    I had the same problem… and the fix it. i’m install fix-rss-feed plugin. It works!

  5. Serge Bóinn says:

    Yep, functions.php here as well.
    Thanks so much for your work!

  6. Neel says:

    Yes most of the times the problem is in the function.php file or in the plugins files.

  7. 工作達人 says:

    Your article help me to slove the problem.SO would you mind me to translate it to Chinese?

  8. Michael says:

    Turned out it was the functions.php for me, as well.

    I totally forgot that I had edited it just before upgrading to WP 2.8.4 for a cleaner function…and ended up creating a bunch of needless extra research for myself, to resolve the problem.

    For those of you who didn’t fall into the “functions.php” category…

    You might want to give the Fix-Rss-Feed plugin a try, it quickly removed blank lines from most .php files in the WordPress directories and would save you a lot of time:

    Just wanted to say thanks for mentioning the functions.php one…I am astonished I missed it.


  9. kazooli says:

    Hi there,
    I have been looking for some information wth regards to xml errors in wordpress. As I produce articles, now and then, I create errors by accident.

    Is there anyhting that I can do to correct these errors automatically or do these have to be manually corrected.

    You seem like the right person to ask and so I hope I have not hijacked your post with my queries.

    All the best

  10. Josh L says:

    Thanks for this post! In my case, it was also the functions.php file, but it was a blank line between two blocks of PHP, rather than at the beginning or end of the file.

  11. Doc4 says:

    Josh L,

    This was the same issue we were having. Thank you for pointing out that spaces between php tags can cause this same malfunction.

  12. Andrei says:

    thank you for this post!
    I finally located the culprit – functions.php – that was causing me headaches.

  13. Shahab khan says:

    Many thanks to you QOT for this article helped me a lot!

  14. Micah says:

    Man, I wish this was as easy as it being a functions.php problem! I went through all the steps but STILL get the same problem as originally described. I am baffled and do not know what to do next!

  15. psycoreownz says:

    uff… you save my life… y tried with the plug-in and doesn’t work, so i start editing all the archives of my template and the ftp server and done! all came back to normally

  16. Clarence says:

    Wow, great post. I was having problem with wordpress for Blackberry and it wouldn’t work, then i found you post, now my blog is accessible from my Blackberry again “blackberry uses xmlrpc”


  17. moonlight says:

    yes its function.php problems.
    i’m fixed the FSS feed error.

    thz all.

  18. Joseph says:

    I just like to say thanks for this info. I am still trying to fix my RSS Feed, but your info has been very helpful. Fingers crossed!!

  19. RestlessCreative says:

    I found this problem to actually be BLANK LINES at the end of the FUNCTIONS.PHP file. Delete those lines.

  20. Clayton says:

    Thanks for the post. I have read about the whitespace problem. And rereading it made me check again and fixed my problem (that I overlooked). Just wanted to say thanks.

  21. Beta says:

    Thanks you, i want to use this fix feed XML parsingeror guide.

  22. Krish says:

    There are many ways to fix this.. Read the below article..Nice one

  23. angad says:

    THanks alot…. u just saved me thanks… i had almost given up…..

  24. Neil says:


    I did all what your post says and I still have the error.. any ideas what it could be?

    • Oxygen says:

      Parse your feed to some XML validator: maybe it will help. Not only blank line could break your rss.

  25. charlotte says:

    Thanks – you helped a lot – it was functions.php for me too.

  26. برامج 2012 says:

    Yep, functions.php here as well.
    Thanks so much for your work!

  27. برامج 2012 says:

    I dont know how can i thank you for this post
    i fixed my rss feed problem by wordpress rss feed fix plugin that you put in the post

    thank you very very very much

  28. Muqthyar says:

    thank a lot, this helped me a lot

  29. Mike says:

    Thnks a lot! was looking for solution for ages ))

  30. Naser @ Tech Blog says:

    Iam getting a different type of error in my wordpress feed: which says: error on line 660 at column 30: Input is not proper UTF-8, indicate encoding !
    Bytes: 0x1C 0x4F 0x70 0x65
    This made my feedburner feed to stop working correctly. Please help me..

  31. homedesign says:

    Yes. So am I. I got that error at function.php..thanks

  32. Mladen says:

    Thank you for your post. It worked for me :)

  33. Basavaraj says:

    Another alternative is use ob_clean(); method just before you want to return your results, this will clean the output buffer so that even if any empty lines going to output, it will be erased before pushing your response

  34. Fabrice COURT says:

    Thanks for this very useful article !

  35. Hugo says:

    Excellent, +1, this is a very useful article, I was looking for one solution, you gave me serveral :)
    Thanks dude !

  36. Cristian says:

    If you disable all pugins, resinstall wp with latest updated fresh files, and use another theme, but problem still there, you will have to remove feed cache from your database:

    DELETE FROM `wp_options` WHERE `option_name` LIKE (‘_transient%_feed_%’)

  37. jasminder says:

    Thx . appreciate

  38. Miguel says:

    Thanks for the excellent tutorial.

  39. Chandrajit Rudra says:

    Thanks a lot…

    This guide is the best step by step guide on fixing an RSS feed… I sat unable to do anything for a few weeks…. fixing my feed..

    ultimately it was ur guide that led me to find the problem.. that was ultimately in my functions.php…

    thanks a ton again…

  40. Lars Eighner says:

    The php closing tag ?> is not necessary at the end of a file. Get out of the habit of using it, and delete it when you find it. This applies only to ?> at the end of a file. Naturally you need it within a file where text is mixed with php.

    Almost all white space problems are caused by white space characters, usually a newline, after the ?> at the end of a file. This is harmful in many situations, not just feeds.

    When you omit the ?> at the end of a file, you cannot (obviously) have white space after it. And white space before the close is harmless.

  41. Alex Cardo says:

    “Feedburner account > Troubleshooting > Resync Feed” This option regenerated my Feedburner Feed, but the feed in my site by the address still doesn’t work!

    WordPress have 1000’s of php files, I can’t check them all!

  42. Kenny says:

    Thank You!!! I had 2 lines of blank code at the very end of my functions.php file.

  43. Devendra Bhardwaj says:

    Many – many thanks to you for this article helped me a lot!

  44. Jeroen Thibaut says:

    Helped me out too, thanks!

  45. Ulysses Alves says:

    Thanks, friend! My blog feeds were not working, with this same error you told above, and this was also preventing my Newsletter from being sent automatically (it’s feed driven).
    I edited my functions.php file as you suggested, and it worked first time! You saved my blog! :D

  46. Cameron Banowsky says:

    If this method doesn’t work because you have a heavily customized theme with a lot of php and room for error, follow these steps….

  47. Arjan D. says:

    Would have never guessed this was the problem! Much appreciated!

  48. Kat Hooper says:

    Thank you. I had added some stuff to my functions.php file and left a couple blank lines at the end. I deleted them and resynced my feeds. Now they work.

  49. sara says:

    I am getting the same error but I just have a web applicqation with no php files. Can anyone help me ???

  50. fredforever says:

    hello admin, i have problem like your posting, thank you, i will try..

  51. Lorraine says:

    Thank you for the excellent tutorial with screenshots and a clear explanation! As a marketer and non-PHP coder, the discussions on the WordPress support forums about this issue that said “remove whitespace from PHP files” left me confused. Seeing your actual screenshots of where you removed the whitespace “line” was really helpful.

    Also, note to others to check your built-in WordPress code editor and not just the PHP files via FTP (Appearance > Editor). It was my functions.php file too but making the change via FTP in both my main and child themes didn’t override what was appearing in functions.php in the built-in editor.

  52. Alney says:

    I got rid of this mess by spending only 5 bucks on Fiverr.

  53. says:

    Thanks, my problem have been fixed!

Leave a Reply

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