Announcement

Collapse
No announcement yet.

wordpress feed error: solve and fix how to white spaces xml declaration feed problem

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • wordpress feed error: solve and fix how to white spaces xml declaration feed problem

    There are many sites all over the internet but i have not find out the solution to solve the problem about wordpress rss feed error.
    Commonly the feed output is corrupted and not well parsed, the result is a browser error like:
    XML Parsing Error: XML or text declaration not at start of entity

    The problem is that before the needed XML declaration
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    there are some white spaces while it is necessary that the very first character of the parsed document is
    Code:
    <
    The common suggested solution is to check one by one on every file for white spaces that are digit out from some Php Start (<?php) and End (?>) tags declarations. It is maybe an hard solution to find out searching on any involved file that is responsible the problem, you need to search between included files, maybe inside some class, function or some other crazy, evil programmer's things. It is commonly suggested to not use the optional Php close tag ( ?> ) on modules or included files as it can cause this wrong behavior that return white spaces just before (as in this case) the needed xml declaration.

    The solution:
    I have think instead the best solution should be to clean up the output just in time, before it is parsed, and by Php. This is the tricky way that solve any problem:
    Code:
    $out = ob_get_contents();
    $out = str_replace(array(”\n”, “\r”, “\t”, ” “), “”, $input);
    ob_end_clean();
    This will fix the feed problem, it is not necessary nothing more. Yet another very useful way to use the Php native function
    Code:
    ob_get_contents()
    There are many other way to use these three lines of code to solve practically any feed problem about wrong characters in the feed output. A new complete article in the w3it.org programming section will be published as soon.
    About wordpress rss feed error solution, please go ahead and read this w3it.org blog page: wordpress feed error, white spaces solution

  • #2
    rss entities parsing error

    Wordpress files/functions used to return in many ways rss feed contents of the blog content, sometimes are returning many other strange behaviors along the way. The above solution is the best way to eliminate white spaces before the start xml declaration in the resultant feed document.
    But there are some more things to fix. For example some characters sequences are recognized as broken entities in Explorer browser and the browser return error. Browsers have different answers to the same code and the same page is correctly parsed by Safary for example, while Firefox interrupt the output before comments feed list display and do not output nothing more than the rss feed title. I'm looking to solve also this kind of problem (that is in any case so much rare respect the white spaces output problem before xml declaration) but i think maybe there are browsers bugs issues that need to be solved by Microsoft for Explorer etc for others. If any suggestion about this thread and argument discussion, please give an help!

    Comment


    • #3
      How to: solution for wordpress comments rss feed entities parse error

      Well, this is the solution where browsers fail with entities recognize and the comments feed of wordpress result corrupt or interrupt.
      The common error is concerning the fact that the permalink characters sequence in some points is recognized as a broken entity.
      For example a typical wordpress permalink result in the feed source will be:
      Code:
      <link>http://www.axew3.com/b10g/?page_id=5&cpage=1#comment-357</link>
      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 contruction let understand to the browser the wrong. The solution is to substitute exactly the character & with his respective entity &amp;. So, the correct returned link/permalink url in the feed source should be:
      Code:
      <link>http://www.axew3.com/b10g/?page_id=5&amp;cpage=1#comment-357</link>
      How to fix this 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():
      Code:
      return add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) ) . '#comment-' . $comment->comment_ID;
      the tricky way is to substitute the above with this code:
      Code:
      return add_query_arg( 'amp;cpage', $args['page'], get_permalink( $comment->comment_post_ID ) ) . '#comment-' . $comment->comment_ID;
      Save and overwrite the original comment-template.php file with the new edited: enjoy now your wordpress comment feed correctly resumed.

      Comment


      • #4
        Thx for you post.. But I have such problem also with main rss wordpress feed. I was trying to find where to add amp; sign to recover my feed with links containing & sign but I didn't find.. May be you could help please..

        Comment


        • #5
          Yes, post the link to your site if you like, so i can understand where you need to search for the code, in which file exactly. By the way, there are the follow files where you can find out the code to be edited:
          feed-rss2-comments.php, feed-rss.php, feed-rdf.php, feed-atom.php, feed-atom-comments.php.
          You can read also this blog page about feed entities problems that is little more detailed.

          Comment


          • #6
            Great, but....

            This looks like the right solution, but in what files/places does this change need to be completed?

            Comment


            • #7
              files to be edited and more

              I think here you'll find all what you need in this blog page:
              http://www.w3it.org/blog/wordpress-f...lution-how-to/
              If you need to know some more, let know.

              Comment


              • #8
                Stuck with &quot;a semi colo character was expected&quot;

                Hello,

                I am kinda stuck with my non-working rss feed. Here is the message I get:

                A semi colon character was expected. Error processing resource 'http://pansponka.com/feed/'. Line 109, Position 104

                <guid isPermaLink="false">http://pansponka.com/well-well-well-what-do-we-have-here/langswitch_lang/&m</guid&g...

                I understand, that the error is because of the "&m" part. But I am unfortunately not able to figure out, where is this permalink "assembled" so I could change it. There is this langswitch plugin, which I updated and which should now use regular permalinks, instead of those with ampersands.

                Unfortunately, even after the upgrade, the RSS feed links are the same and I am not sure how to update them or edit them. Is this somehow possible? Can you advise on this?

                Any help would be highly appreciated.

                Thanks,
                Michal.

                Comment


                • #9
                  characters recognized as entities from browsers

                  as also described in the tutorial post of the w3it.org blog about feed errors and how to fix problems about blank spaces and entities parsing also in this case for your feed there is a browser misunderstanding about entities.
                  In your case this is the line that return the problem and broke the feed result:
                  Code:
                  <guid isPermaLink="false">http://pansponka.com/?p=414&amp;langswitch_lang=&m</guid>
                  the &m characters in this line let understand to the browser the wrong that try to convert it.
                  The best way to solve your problem seem to be modify the link that cause the problem in this exact post titled Definice práce. Try to modify the link in this way:
                  Code:
                  http://pansponka.com/?p=414
                  This is the more speedy way if there aren't more strange links in your posts. Otherwise it is necessary to find out another solution.

                  Comment


                  • #10
                    Hi,

                    I am facing rss feed xml parsing error and feed is also not working.

                    Check this link
                    http://feedvalidator.org/check.cgi?u...%2Fblog%2Ffeed

                    Kindly provide me the solution to resolve this issue.

                    Thanks in advance
                    Soney

                    Comment


                    • #11
                      Till now i didn't get any reply for my post.

                      Still waiting for solution

                      Comment


                      • #12
                        sorry soney, it is too late for answer but many problems have come out here and this thread have go away, now i have read your latest addition and question, but i'm sorry because also i've not understand what's the problem you need to solve and/or if still you have problems, or as i hope, you have finally solve it. Let know and best regards.

                        Comment

                        Previously entered content was automatically saved. Restore or Discard.
                        Auto-Saved
                        x
                        Insert: Thumbnail Small Medium Large Fullsize Remove  
                        x
                        x
                        Working...
                        X