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 7057895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:02:53+00:00 2026-05-28T04:02:53+00:00

I am trying to parse out xml feeds from different sources, some news feeds

  • 0

I am trying to parse out xml feeds from different sources, some news feeds following the rss2.0 standard and others from different sources like twitter, facebook (which actually gives me the option for rss2.0) and linkedIn. Everything was working perfectly until I threw facebook into the mix. I passed rss20 as the format so it should follow the same standards as a normal rss feed and fit right into my code but it’s throwing the error An error occurred while parsing EntityName and referencing this line…

XPathNavigator xpn = new XPathDocument(Server.UrlDecode(XmlHelper.GetXmlFeedUrl(appSettings[x]))).CreateNavigator();

In my research I found that there is no header set for the facebook feed (research). But I’m not quit sure this applies or if there is a completely better way to go about this. I’ve thought about SyndicationFeed but since twitter doesn’t follow atom or rss I don’t think it would work.

Here’s the facebook url…

http://www.facebook.com/feeds/page.php?format=rss20%26id=6198772858

Here is my code…

protected void Page_Load(object sender, EventArgs e)
{
    XmlFeedItemPath xfip;
    NameValueCollection appSettings = ConfigurationManager.AppSettings;
    List<string> xmlFeeds = appSettings.AllKeys.Where(x => x.StartsWith("XmlFeed")).ToList();
    string currentXmlFeedType;
    if(!string.IsNullOrEmpty(xmlFeedType))
        xmlFeeds.RemoveAll(s => !appSettings[s].Contains(XmlFeedType));

    xmlFeeds.ForEach(x =>
    {   
        currentXmlFeedType = XmlHelper.GetXmlFeedType(appSettings[x]);
        xfip = XmlHelper.GetXmlFeedItemPath(currentXmlFeedType);
        XPathNavigator xpn = new XPathDocument(Server.UrlDecode(XmlHelper.GetXmlFeedUrl(appSettings[x]))).CreateNavigator();
        XmlNamespaceManager xmlnsm = XmlHelper.GetXmlNameSpaceManager(xpn);
        XPathNodeIterator nodes = xpn.Select(xfip.IteratorPath, xmlnsm);
        int i = 0;
        foreach (XPathNavigator node in nodes)
        {
            XmlFeedItems.Add(new XmlFeedItem()
            {
                Title = string.IsNullOrEmpty(xfip.TitlePath) ? xfip.DefaultTitle : node.SelectSingleNode(xfip.TitlePath, xmlnsm).ToString(),
                Link = string.IsNullOrEmpty(xfip.LinkPath) ? null : node.SelectSingleNode(xfip.LinkPath, xmlnsm).ToString(),
                Teaser = string.IsNullOrEmpty(xfip.TeaserPath) ? null : XmlHelper.WrapUrlWithAnchorTags(node.SelectSingleNode(xfip.TeaserPath, xmlnsm).ToString()),
                Source = string.IsNullOrEmpty(xfip.SourcePath) ? null : xpn.SelectSingleNode(xfip.SourcePath, xmlnsm).ToString(),
                SortOrder = i,
                XmlFeedType = currentXmlFeedType 
            });
            i++;
        }
    });

    rptRssFeed.DataSource = XmlFeedItems.OrderBy(x => x.SortOrder).Take(10);
    rptRssFeed.DataBind();
}
  • 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-28T04:02:53+00:00Added an answer on May 28, 2026 at 4:02 am

    I figured it out. Since the facebook feed did not have a useragent string I had to change my implementation to use HttpWebRequest and manually set a useragent for each xml feed (facebook included)….

    protected void Page_Load(object sender, EventArgs e)
    {
        XmlFeedItemPath xfip;
        NameValueCollection appSettings = ConfigurationManager.AppSettings;
        List<string> xmlFeeds = appSettings.AllKeys.Where(x => x.StartsWith("XmlFeed")).ToList();
        string currentXmlFeedType;
        if(!string.IsNullOrEmpty(xmlFeedType))
            xmlFeeds.RemoveAll(s => !appSettings[s].Contains(XmlFeedType));
    
        xmlFeeds.ForEach(x =>
        {   
            currentXmlFeedType = XmlHelper.GetXmlFeedType(appSettings[x]);
            xfip = XmlHelper.GetXmlFeedItemPath(currentXmlFeedType);
    
            var request = (HttpWebRequest)WebRequest.Create(Server.UrlDecode(XmlHelper.GetXmlFeedUrl(appSettings[x])));
            request.Method = "GET";
            request.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)";
            XPathNavigator xpn = new XPathDocument(XmlReader.Create(request.GetResponse().GetResponseStream())).CreateNavigator();
            XmlNamespaceManager xmlnsm = XmlHelper.GetXmlNameSpaceManager(xpn);
            XPathNodeIterator nodes = xpn.Select(xfip.IteratorPath, xmlnsm);
    
            int i = 0;
            foreach (XPathNavigator node in nodes)
            {
                string publishDate = string.IsNullOrEmpty(xfip.PublishDatePath) ? null : node.SelectSingleNode(xfip.PublishDatePath, xmlnsm).ToString();
                XmlFeedItems.Add(new XmlFeedItem()
                {
                    Title = string.IsNullOrEmpty(xfip.TitlePath) ? xfip.DefaultTitle : node.SelectSingleNode(xfip.TitlePath, xmlnsm).ToString(),
                    Link = string.IsNullOrEmpty(xfip.LinkPath) ? null : node.SelectSingleNode(xfip.LinkPath, xmlnsm).ToString(),
                    Teaser = string.IsNullOrEmpty(xfip.TeaserPath) ? null : XmlHelper.WrapUrlWithAnchorTags(HttpUtility.HtmlDecode(node.SelectSingleNode(xfip.TeaserPath, xmlnsm).ToString())),
                    Source = string.IsNullOrEmpty(xfip.SourcePath) ? null : xpn.SelectSingleNode(xfip.SourcePath, xmlnsm).ToString(),
                    SortOrder = i,
                    XmlFeedType = currentXmlFeedType,
                    PublishDate = string.IsNullOrEmpty(publishDate) ? new DateTime() : DateTime.Parse(publishDate.Remove(publishDate.IndexOf(" +")))
                });
                i++;
            }
        });
    
        rptRssFeed.DataSource = XmlFeedItems.OrderBy(x => x.GetType().GetProperty(sortField)).Take(10);
        rptRssFeed.DataBind();
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse some XML I've gotten from the Google Data Booksearch API
I am trying to parse XML feeds from YouTube using jQuery (by doing $(xml).find(...)
I am trying to parse out some information from Google's geocoding API but I
I trying to parse the message element out of the following XML fragment using
Trying to parse some XML but apparently this is too much for a lazy
I'm trying to parse out the XML below with the PHP code shown here
I am trying to create a for loop that will parse out different elements
I'm trying to use feedparser to retrieve some specific information from feeds, but also
Hi I am trying to parse data out of an XML file I exported
I am trying to parse an XML file I made and pull information out

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.