Title: Feed Output Error Solution
Last modified: August 19, 2016

---

# Feed Output Error Solution

 *  Resolved [rainer23](https://wordpress.org/support/users/rainer23/)
 * (@rainer23)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/feed-output-error-solution/)
 * After weeeks of unsuccessful search, this finally solved my blog being cut off
   from feedburner:
 * **How to remove white spaces and fix problems**
    [http://www.w3it.org/blog/wordpress-feed-error-output-solution-how-to/](http://www.w3it.org/blog/wordpress-feed-error-output-solution-how-to/)
   The wordpress feed sometime return error and you can’t find out the way to solve
   the problem about white spaces output before the XML declaration, and that is
   responsible of the broken result.
 * I had the same problem in this online blog feed, while on my localhost LAMP test
   server all was correctly returned and the feed displayed without errors.
 * The common error is:
 *  XML Parsing Error: XML or text declaration not at start of entity
 * Or, if you are validating a page using the w3 validator:
 *  XML Parsing Error: XML declaration allowed only at the start of the document
 * This means that before the < character there are unwanted characters that need
   to be eliminated (also white spaces) for a clean and correct XML declaration.
   
   <?xml version=”1.0″ encoding=”UTF-8″?> Thinking on how to solve the problem, 
   and after many wrong reads all over internet the easy solution have come out 
   in my simple mind. What we need, is to add a little tip in specific files where
   wordpress feeds are made up before to be outputted to the browser on request.
   So, we go to fix this by opening the follow file, if the feed we want is RSS2
   in wordpress (we will see all any other after in any case):
 * wp-includes/feed-rss2.php
 * open it with a text editor and read on the very top section, the following code:
 * header(‘Content-Type: text/xml; charset=’ . get_option(‘blog_charset’), true);
   
   $more = 1;
 * To fix the feed on wordpress (but not only, it is obviously valid in, and for,
   any other feed or non feed contest where we can have the same necessity), add
   this tricky Php code immediately after:
 * $out = ob_get_contents();
    $out = str_replace(array(“\n”, “\r”, “\t”, ” “), “”,
   $input); ob_end_clean();
 * Do the same almost with the comment’s feed file: feed-rss2-comments.php
    Save/
   replace the feed-rss2.php and the feed-rss2-comments.php files modified in this
   way and enjoy your re-enabled feeds!
 * see the fixed w3it.org blog feed
 * Note that not only the file feed-rss2.php on wordpress is able and used for feed
   purpose. In the same way, you may need to edit the following files if the requested
   feed is another:
    feed-rss2-comments.php, feed-rss.php, feed-rdf.php, feed-atom.
   php, feed-atom-comments.php.
 * There is also another strange behavior where browsers fail with entities recognize
   and the comments feed of wordpress result corrupt or interrupt.
    The common error
   is concerning the fact that in wordpress is possible to set permalinks (SEO) 
   and in this case, sometime, the characters sequences in some points are recognized
   like broken entity. For example a typical wordpress link result in the feed source
   will be:
 * [http://www.axew3.com/b10g/?page_id=5&cpage=1#comment-357](http://www.axew3.com/b10g/?page_id=5&cpage=1#comment-357)
   
   The &cpage sequence is recognized in explorer as broken entity, it return error
   asking for the ; char ( entity &cpage; ) . Really there is no entities &cpage;
   for what i know, but the character & in the link let understand to the browser
   the wrong. The solution is to substitute exactly the character & with his respective
   entity. The correct returned link url in the feed source should be:
 * [http://www.axew3.com/b10g/?page_id=5&cpage=1#comment-357](http://www.axew3.com/b10g/?page_id=5&cpage=1#comment-357)
   
   So, where to edit fixing this problem for the wordpress comments feed returning
   error? This is the tricky way to solve: Open the wordpress file wp-includes/comment-
   template.php and search for this line contained inside the function get_comment_link():
   return add_query_arg( ‘cpage’, $args[‘page’], get_permalink( $comment->comment_post_ID)).‘#
   comment-‘ . $comment->comment_ID; substitute the above with this code: return
   add_query_arg( ‘amp;cpage’, $args[‘page’], get_permalink( $comment->comment_post_ID)).‘#
   comment-‘ . $comment->comment_ID; Note the trick is this: we go to add exactly
   amp; and not & as the char & has already been added in another function that 
   contribute with this to build the link Url. Save and overwrite the original comment-
   template.php file with the new edited: enjoy now your wordpress comment feed 
   correctly parsed.

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [melkiades47](https://wordpress.org/support/users/melkiades47/)
 * (@melkiades47)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/feed-output-error-solution/#post-1281920)
 * Great solution
 *  [Robert Ferreira](https://wordpress.org/support/users/ibprosource/)
 * (@ibprosource)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/feed-output-error-solution/#post-1281927)
 * This did not work for my rss2 feed. I still receive this error:
 * XML Parsing Error: XML or text declaration not at start of entity
    Location: 
   [http://ibprosource.com/?feed=rss2](http://ibprosource.com/?feed=rss2) Line Number
   2, Column 1:<?xml version=”1.0″ encoding=”UTF-8″?> ^
 * Any further help would greatly be appreciated. This is what I inserted into the
   xmlrpc.php file…
 *     ```
       /** Include the bootstrap for setting up WordPress environment */
       include('./wp-load.php');
   
       if ( isset( $_GET['rsd'] ) ) { // http://archipelago.phrasewise.com/rsd
       header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
       <blockquote>$out = ob_get_contents();
       $out = str_replace(array("\n", "\r", "\t", " "), "", $input);
       ob_end_clean();</blockquote>
       ?>
       <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
       <rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
         <service>
       ```
   
 * Thanks in advance for your help.
 * Robert
 *  [Robert Ferreira](https://wordpress.org/support/users/ibprosource/)
 * (@ibprosource)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/feed-output-error-solution/#post-1281928)
 * OK, so I’m still having the same issue after this ‘fix’. Any further help would
   be greatly appreciated. Thank you
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/feed-output-error-solution/#post-1281929)
 * Have you tried:
 * – deactivating **all** plugins to see if this resolves the problem? If this works,
   re-activate the plugins one by one until you find the problematic plugin(s).
 * – switching to the default theme to rule out any theme-specific problems?
 * – [resetting the plugins folder](http://codex.wordpress.org/FAQ_Troubleshooting#How_to_deactivate_all_plugins_when_not_able_to_access_the_administrative_menus.3F)
   by FTP or phpMyAdmin? Sometimes, an apparently inactive plugin can still cause
   problems.
 * – checking your theme’s template files for leading blank lines?
 *  [Robert Ferreira](https://wordpress.org/support/users/ibprosource/)
 * (@ibprosource)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/feed-output-error-solution/#post-1281930)
 * I’ve actually done this yesterday. I downloaded the fix-rss-feed plugin a couple
   days ago, and when I did a check, it came back with nearly 1000 errors! So, naturally,
   I went ahead and clicked the ‘fix’ button with the plugin. Well, doing this destroyed
   my site! It took me 2 days just to regain access to the admin dashboard. I ended
   up disabling all plugins, deleted a few through ftp, renamed the template folder
   so WP would default back, but the problem still exists. My feed isn’t showing
   up! Not understanding how this could have happened. Still getting this error:
 *     ```
       XML Parsing Error: XML or text declaration not at start of entity
       Location: http://ibprosource.com/?feed=rss2
       Line Number 2, Column 1:<?xml version="1.0" encoding="UTF-8"?>
       ^
       ```
   
 * Thanks for your response.
    Oh, and I made the change to the correct rss2 files.
   I fixed the xmlrpc.php back to it’s original code. Thanks again.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/feed-output-error-solution/#post-1281931)
 * I’d suggest re-uploading all files & folders – with the **exception** of the 
   wp-content folder – from a **fresh** download of your version of WordPress and
   re-uploading a fresh copy of your current theme.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Feed Output Error Solution’ is closed to new replies.

## Tags

 * [xml](https://wordpress.org/support/topic-tag/xml/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 4 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/feed-output-error-solution/#post-1281931)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
