Tuesday, 27 September 2011

How to avoid the “XML Parsing Error: XML or text declaration not at start of entity” in wordpress feed?

Web feed or news feed is a format which is to represent the updated data for the users or subscribers. Wordpress has in built functionality for the generation of rss feeds for website.

Sometimes while accessing the rss feed it will throw a parsing error i.e

XML Parsing Error: XML or text declaration not at start of entity.

This error will cause if there is a blank space in the theme files or in the core files of wordpress.
To avoid this error remove the blank spaces before or after the <?php ?> tags  or add the following code.

We have different plug-ins to check the spaces in the files and to remove ,but the best solution is to add the following code. I resolved the problem is like this only. Adding a piece of code is better than using one more plugin for a website.Its better to use very less plug-ins for a website.

$out = ob_get_contents();  
$out = str_replace(array("\n", "\r", "\t", " "), "", $input);

Add this code in the following files ,located root directory of your  wordpress site.


No comments:

Post a Comment