Fixing wordpress RSS XML parsing errors

Wordpress RSS feeds can be annoying. Really annoying. If you install a bad plugin, theme, or even edit some of the existing php files you might find your RSS feeds start getting this parsing error.

XML Parsing Error: xml declaration not at start of external entity
Line Number 3, Column 1:<?xml version="1.0" encoding="UTF-8"?>

You might find that enabling output buffering for your RSS feeds might sort you out, as suggested by J Wynia. But unfortunately it didn’t do it for me.

So, go to the source and fix up the files causing you problems, with the following perl script. It will check each of your php files for any that have extra line feeds at the start, or end – and remove them. You’ll need SSH / command line access for this, as well as perl installed.

Use it at your own risk. It worked for me, but is otherwise untested – so, make a backup first ๐Ÿ™‚

Instructions

  1. Backup your wordpress installation
  2. Download the script to the root directory of your wordpress installation.
  3. cd to your installation directory.
  4. Run the script: perl fix-rss-xml-spacing.txt.
  5. Fingers crossed, your RSS feeds will now work again (and hopefully, so will the rest of your blog).

Good luck!

Tags: ,

Leave a Reply?