XML Parsing Error in WordPress post RSS or comment RSS

Sometimes you might have following kind of error message in wordpress.

XML Parsing Error: XML or text declaration not at start of entity
Location: http://example.com/comments/feed/
Line Number 5, Column 1:

or

XML Parsing Error: XML or text declaration not at start of entity
Location: http://example.com/feed/
Line Number 5, Column 1:

If you view the page source, you will see some blank lines before the xml declaration.

It might happen for number of reasons.

But common reasons are,

Somewhere in your application, it could be core wordpress or any plugin or your theme, who is generating those blank lines.

commonly used solution is, use

ob_end_clean();

to clean those blank lines.
put this function into

wp-blog-header.php

immediately after

require_once( dirname(__FILE__) . '/wp-load.php' );

If still this doesn’t solve your problem, do some debugging with,

echo "somethig to make sure which included file is generating those blank lines";

ob_flush(); die;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s