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

  • Home
  • SEARCH
  • 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 538991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:05:23+00:00 2026-05-13T10:05:23+00:00

I’m writing a Stack Overflow API wrapper , currently at http://soapidotnet.googlecode.com/ . I have

  • 0

I’m writing a Stack Overflow API wrapper, currently at http://soapidotnet.googlecode.com/. I have a few questions about parsing SO RSS feeds.

I’ve chosen to use RSS.NET to parse the RSS, but I have a few questions about my code (which I have provided further down in this post).


My Questions:

First of all, am I parsing those attributes correctly? I have a class named Question, which has those properties.

Next, how can I parse the <re:rank> RSS property (used for # of votes)? I’m not sure how RSS.NET lets us do that. As far as I understand, it’s a element with a custom namespace.

Finally, do I have to add all the properties manually, like currently in my code? Is their some sort of deserialization that I can use?


Code:

Below is my current code for parsing recent question feeds:

   /// <summary>
    /// Utilises recent question feeds to obtain recently updated questions on a certain site.
    /// </summary>
    /// <param name="site">Trilogy site in question.</param>
    /// <returns>A list of objects of type Question, which represents the recent questions on a trilogy site.</returns>
    public static List<Question> GetRecentQuestions(TrilogySite site)
    {
        List<Question> RecentQuestions = new List<Question>();
        RssFeed feed = RssFeed.Load(string.Format("http://{0}.com/feeds",GetSiteUrl(site)));
        RssChannel channel = (RssChannel)feed.Channels[0];
        foreach (RssItem item in channel.Items)
        {
            Question toadd = new Question();
            foreach(RssCategory cat in item.Categories)
            {
                toadd.Categories.Add(cat.Name);
            }
            toadd.Author = item.Author;
            toadd.CreatedDate = ConvertToUnixTimestamp(item.PubDate).ToString();
            toadd.Id = item.Link.Url.ToString();
            toadd.Link = item.Link.Url.ToString();
            toadd.Summary = item.Description;

            //TODO: OTHER PROPERTIES
            RecentQuestions.Add(toadd);
        }
        return RecentQuestions;
    }

Here is the code of that SO RSS feed:

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:re="http://purl.org/atompub/rank/1.0"> 
    <title type="text">Top Questions - Stack Overflow</title> 
    <link rel="self" href="http://stackoverflow.com/feeds" type="application/atom+xml" /> 
    <link rel="alternate" href="http://stackoverflow.com/questions" type="text/html" /> 
    <subtitle>most recent 30 from stackoverflow.com</subtitle> 
    <updated>2009-11-28T19:26:49Z</updated> 
    <id>http://stackoverflow.com/feeds</id> 
    <creativeCommons:license>http://www.creativecommons.org/licenses/by-nc/2.5/rdf</creativeCommons:license> 

    <entry> 
        <id>http://stackoverflow.com/questions/1813483/averaging-angles-again</id> 
        <re:rank scheme="http://stackoverflow.com">0</re:rank> 
        <title type="text">Averaging angles... Again</title> 
        <category scheme="http://stackoverflow.com/feeds/tags" term="algorithm"/><category scheme="http://stackoverflow.com/feeds/tags" term="math"/><category scheme="http://stackoverflow.com/feeds/tags" term="geometry"/><category scheme="http://stackoverflow.com/feeds/tags" term="calculation"/> 
        <author><name>Lior Kogan</name></author> 
        <link rel="alternate" href="http://stackoverflow.com/questions/1813483/averaging-angles-again" /> 
        <published>2009-11-28T19:19:13Z</published> 
        <updated>2009-11-28T19:26:39Z</updated> 
        <summary type="html"> 
            &lt;p&gt;I want to calculate the average of a set of angles.&lt;/p&gt;

&lt;p&gt;I know it has been discussed before (several times). The accepted answer was &lt;strong&gt;Compute unit vectors from the angles and take the angle of their average&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;However this answer defines the average in a non intuitive way. The average of 0, 0 and 90 will be &lt;strong&gt;atan( (sin(0)+sin(0)+sin(90)) / (cos(0)+cos(0)+cos(90)) ) = atan(1/2)= 26.56 deg&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;I would expect the average of 0, 0 and 90 to be 30 degrees.&lt;/p&gt;

&lt;p&gt;So I think it is fair to ask the question again: How would you calculate the average, so such examples will give the intuitive expected answer.&lt;/p&gt;

        </summary> 
    </entry> 

etc.

Here is my Question class, if it will help:

    /// <summary>
    /// Represents a question.
    /// </summary>
    public class Question : Post //TODO: Have Question and Answer derive from Post
    {

        /// <summary>
        /// # of favorites.
        /// </summary>
        public double FavCount { get; set; }

        /// <summary>
        /// # of answers.
        /// </summary>
        public double AnswerCount { get; set; }

        /// <summary>
        /// Tags.
        /// </summary>
        public string Tags { get; set; }

    }


/// <summary>
    /// Represents a post on Stack Overflow (question, answer, or comment).
    /// </summary>
    public class Post
    {
        /// <summary>
        /// Id (link)
        /// </summary>
        public string Id { get; set; }
        /// <summary>
        /// Number of votes.
        /// </summary>
        public double VoteCount { get; set; }
        /// <summary>
        /// Number of views.
        /// </summary>
        public double ViewCount { get; set; }
        /// <summary>
        /// Title.
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// Created date of the post (expressed as a Unix timestamp)
        /// </summary>
        public string CreatedDate
        {

            get
            {
                return CreatedDate;
            }
            set
            {
                CreatedDate = value;
                dtCreatedDate = StackOverflow.ConvertFromUnixTimestamp(StackOverflow.ExtractTimestampFromJsonTime(value));

            }

        }
        /// <summary>
        /// Created date of the post (expressed as a DateTime)
        /// </summary>
        public DateTime dtCreatedDate { get; set; }
        /// <summary>
        /// Last edit date of the post (expressed as a Unix timestamp)
        /// </summary>
        public string LastEditDate
        {

            get
            {
                return LastEditDate;
            }
            set
            {
                LastEditDate = value;
                dtLastEditDate = StackOverflow.ConvertFromUnixTimestamp(StackOverflow.ExtractTimestampFromJsonTime(value));

            }

        }
        /// <summary>
        /// Last edit date of the post (expressed as a DateTime)
        /// </summary>
        public DateTime dtLastEditDate { get; set; }
        /// <summary>
        /// Author of the post.
        /// </summary>
        public string Author { get; set; }
        /// <summary>
        /// HTML of the post.
        /// </summary>
        public string Summary { get; set; }
        /// <summary>
        /// URL of the post.
        /// </summary>
        public string Link { get; set; }
        /// <summary>
        /// RSS Categories (or tags) of the post.
        /// </summary>
        public List<string> Categories { get; set; }

    }

Thanks in advance!
Btw, please contribute to the library project! 🙂

  • 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-13T10:05:23+00:00Added an answer on May 13, 2026 at 10:05 am

    Firstly, I’ve never used RSS.NET but I wondered whether you realised that the .NET framework has it’s own RSS api within the System.ServiceModel.Syncidation namespace. The SyndicationFeed class is the starting point for this.

    To address your question I’ve written a little sample that takes the feed for this question and writes out the title, author, id and the rank (the extension element you’re interested) to the console. This should help show you how simple this API is and how to access the rank.

    // load the raw feed
    using (var xmlr = XmlReader.Create("https://stackoverflow.com/feeds/question/1813559"))
    {
        // get the items within a feed
        var feedItems = SyndicationFeed
                            .Load(xmlr)
                            .GetRss20Formatter()
                            .Feed
                            .Items;
    
        // print out details about each item in the feed
        foreach (var item in feedItems)
        {
            Console.WriteLine("Title: {0}", item.Title.Text); 
            Console.WriteLine("Author: {0}", item.Authors.First().Name);
            Console.WriteLine("Id: {0}", item.Id);
    
            // the extensions assume that there can be more than one value, so get
            // the first or default value (default == 0)
            int rank = item.ElementExtensions
                            .ReadElementExtensions<int>("rank", "http://purl.org/atompub/rank/1.0")
                            .FirstOrDefault();
    
            Console.WriteLine("Rank: {0}", rank);  
        }
    }
    

    The above code results in the following being written to the console…

    Title: .NET/C#: Using RSS.NET with Stack Overflow Feeds: How To Handle Special Properties of RSS Items

    Author: Maxim Z.

    Id: .NET/C#: Using RSS.NET with Stack Overflow Feeds: How To Handle Special Properties of RSS Items?

    Rank: 0

    For more information about the SyndicationFeed class go here…

    http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx

    For some examples of reading and writing extended values from RSS feeds go here…

    http://msdn.microsoft.com/en-us/library/bb943475.aspx

    With regard to creating your Question instances I’m not sure there’s a quick win with serialization. I would have probably written your code something more like this…

    var questions = from item in feedItems
                    select
                        new Question
                            {
                                Title = item.Title.Text,
                                Author = item.Authors.First().Name,
                                Id = item.Id,
                                Rank = item.ElementExtensions.ReadElementExtensions<int>(
                                    "rank", "http://purl.org/atompub/rank/1.0").FirstOrDefault()
                            };
    

    … but it’s pretty much doing the same thing.

    The stuff above requires .NET 3.5 libraries be installed. The following doesn’t, but requires C# 3.5 (which will create assemblies that target .NET 2.0)

    One thing I would suggest you consider – don’t create custom types but, instead, write extension methods for the SyndicationItem type. If you let your users deal with SyndicationType (a type that is supported, understood, documented etc) but add extension methods to make accessing SO specific properties easier then you make the user’s life easier and they can always fall back to the SyndicationItem API when your SO extentions don’t do what they want. So, for example, if you wrote this extension method…

    public static class SOExtensions
    {
        public static int Rank(this SyndicationItem item)
        {
            return item.ElementExtensions
                       .ReadElementExtensions<int>("rank", "http://purl.org/atompub/rank/1.0")
                       .FirstOrDefault();
        }
    }
    

    … you could access the Rank of a SyndicationItem like this…

    Console.WriteLine("Rank: {0}", item.Rank());  
    

    … and when SO add some other extention property to the feed that you’ve not catered for the user of your API can fall back to looking at the ElementExtensions collection.

    One final update…

    I’ve not used the Rss.NET library, but I’ve read through the online docs. From an initial reading of these documents I would suggest that there isn’t a way of getting to the extension element that you’re trying to access (the Rank of the item). If the RSS.NET API allowes access to the xml for a given RssItem (and I’m not sure that it does) then you could have employed the extension method mechanism to augment the RssItem class.

    I find the SyndicationFeed API very powerful and very easy to get to grips with, so if using .NET 3.5 is an option for you then I’d go in that direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 489k
  • Answers 489k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Retina Display version will use a higher resolution of an… May 16, 2026 at 8:55 am
  • Editorial Team
    Editorial Team added an answer No, when you terminate a JVM there's not much you… May 16, 2026 at 8:55 am
  • Editorial Team
    Editorial Team added an answer Very simple solution in the end - just called SeleniumTestCase's… May 16, 2026 at 8:55 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

No related questions found

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.