1

The only article I could find on this was Consuming RSS 1.0 (RDF) Feeds in ASP.NET MVC 3. It uses LINQ. Is there anyway to do it using a lambda expression? Is there any better way to consume and RSS feed in MVC3?

Here is my code:

Imports System
Imports System.Xml
Imports System.ServiceModel
Imports System.ServiceModel.Description
Imports System.ServiceModel.Syndication
Imports System.ServiceModel.Web
Imports System.Collections.ObjectModel
Imports System.Collections.Generic

Public Class RssController

    Function GetFeed(url As String) As SyndicationFeed

        Dim reader = XmlReader.Create(url)
        Dim feed = SyndicationFeed.Load(reader)
        Return feed

    End Function

    Function ShowFeed() As ViewResult

        Dim feedUrl = "somefeedurl"
        Dim feed = GetFeed(feedUrl)
        Return View(feed)

    End Function

End Class
Community
  • 1
  • 1
user1477388
  • 20,790
  • 32
  • 144
  • 264

1 Answers1

3

.NET has a builtin class for handling RSS feeds called SyndicationFeed

You can use this class as an alternative for writing your own parsing logic.

Martin Devillers
  • 17,293
  • 5
  • 46
  • 88
  • That article seems to show how to create but not consume. Can you post an example of RSS consumption? I found this http://stackoverflow.com/questions/369794/good-and-full-implementation-of-rss-feeds-in-asp-net-mvc?rq=1 but was looking for more info. – user1477388 Aug 13 '12 at 18:40
  • http://msdn.microsoft.com/en-us/library/bb412174.aspx has a full example of providing and consuming a RSS-feed using the SyndicationFeed – Martin Devillers Aug 13 '12 at 19:00
  • How do I output the feed? It says, "View is a type and cannot be used as an expression" on the line Return View(feed). Please let me know if you're not sure so I can promptly ask a new question. – user1477388 Aug 13 '12 at 19:21
  • 1
    I'm not familiar with MVC in VB. you may need to extract the data from the SyndicationFeed Items collection and transform it to a Model, but I think if you use IEmumerable of SyndicationItem as the model in your HTML view that should work – Martin Devillers Aug 13 '12 at 19:33