[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

RSS feed reading

My application reads a rss feed that contains posts by categories, and i have those categories pragmatically inserted in the code. What i want to know is how to read a rss feed and generate the categories for the tableview dynamically.

Best Regards.
0
BrunoSurprise
Asked:
BrunoSurprise
1 Solution
 
Lalit ChandraCommented:
create a class

public class RSSItem
{
    public string title {get;set;}
    public string link  {get;set;}
    public string description  {get;set;}
 }

 then use linq to get a collection of RSSItem

public List<RSSItem> items;
 XElement rssFeed = XElement.Load(url).Element("channel");
 items = (from Item in rssFeed.Elements("item")
                 select new RSSItem()
                 {
                     title = Item.Element("title").Value,
                     description = Item.Element("description").Value,
                     link = Item.Element("link").Value
                 }).ToList<RSSItem>();


Now,you can iterate over the collection  rssFeed using ForEach ,and get your desire format.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now