Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6725521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:49:04+00:00 2026-05-26T09:49:04+00:00

I have written a piece of code which uses System.ServiceModel.Syndication library to parse RSS

  • 0

I have written a piece of code which uses System.ServiceModel.Syndication library to parse RSS feeds.

The problem is that for one of my feeds (which is provided by facebook) I get the following line in the end of the response and Syndication library fails to parse the feed because it says the text is invalid XML and it says it’s because of this part:

  ...
  </channel>
  <access:restriction relationship="deny" xmlns:access="http://www.bloglines.com/about/specs/fac-1.0" />
</rss>

I’m sure there is something I’m missing here, because both the feed and the parsing library are from huge companies (Facebook and Microsoft respectively).

Can any of you help? Or alternatively a better parser that doesn’t rely on the validity of XML?

P.S. Here is my RSS feed url:
http://www.facebook.com/feeds/page.php?id=202296766494181&format=rss20

Here is how I’m parsing the feed response:

var stringReader = new StringReader(resp);
var xreader = XmlReader.Create(stringReader);
var xfeed = System.ServiceModel.Syndication.SyndicationFeed.Load(xreader);

and the exception I get:

System.Xml.XmlException: 'Element' is an invalid XmlNodeType. Line 282, position 4.

at System.Xml.XmlReader.ReadEndElement() …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:49:05+00:00Added an answer on May 26, 2026 at 9:49 am

    It seems the SyndicationFeed is having a problem with the access:restriction element used by facebook. See recent thread on http://social.msdn.microsoft.com/Forums/ar/xmlandnetfx/thread/7045dc1c-1bd9-409a-9568-543e74f4578d

    Michael Sun (MSFT) wrote “Just saw Martin’s post! Very helpful! I also did some research about the issue. The element is from Bloglines, http://www.bloglines.com/index.html. It sounds like an extension facebook is using for its RSS 2.0 feeds, http://www.feedforall.com/access-namespace.htm. From this article, it seems Rss20FeedFormatter is not the only one which does not support the elements.

    I agree with Martin to use XDocument (LINQ to XML) to parse the RSS feed. Or if you are building some large app via C#, the Facebook C# SDK can be helpful as well, http://facebooksdk.codeplex.com/“

    Edit :

    It seems however that the Atomfeed is not suffering from this problem. So easiest solution
    would be to use this link (http://www.facebook.com/feeds/page.php?id=202296766494181&format=atom10). Thus changing the format parameter from rss20 to atom10

        HttpWebRequest req = WebRequest.Create(@"http://www.facebook.com/feeds/page.php?id=202296766494181&format=atom10") as HttpWebRequest;
            req.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)";
            using (Stream responseStream = req.GetResponse().GetResponseStream())
            {
                using (XmlReader xr = XmlReader.Create(responseStream))
                {
                    SyndicationFeed feed = SyndicationFeed.Load(xr);
                }
            }
    

    Other alternative is to write an inherited XMLTextReader overiding the ReadEndElement Method, by skipping any Element after the channel closing tag.(Do mind that code below is without any guarantee as I consider myself still a novice c# developer. Please feel free to correct any possible mistakes)

    public class FaceBookReader : XmlTextReader
    {
        public FaceBookReader(Stream stream)
            : base(stream) { }
    
        public FaceBookReader(String url)
            : base(url) { }
    
        public override void ReadEndElement()
        {
            string elementTag = this.LocalName.ToLower();
    
            base.ReadEndElement();
    
            // When we've read the channel End Tag, we're going to skip all tags
            // until we reach the a new Ending Tag which should be that of rss
            if (elementTag == "channel")
            {
                while (base.IsStartElement())
                {
                    base.Skip();
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a piece of code which uses the PdfSharp library. The instance
I have written a piece of code which writes either to console or to
I have written a small piece of code which handles the input of a
I have a piece of code for which cccheck tells me that a Requires()
I have written a piece of code and it runs fine on my system.
I have written a piece of Java code which is intended as to call
I have written a piece of a code which is supposed to read the
I have written a piece of code to simulate mouse click which is working
I have written a piece of code in python, in which I am asking
I have written some piece of code for my program in Matlab 7.10.0 which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.