user1477388
user1477388

Reputation: 21440

Consuming RSS Feeds in VB ASP.NET MVC 3

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

Upvotes: 1

Views: 1489

Answers (1)

Martin Devillers
Martin Devillers

Reputation: 18012

.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.

Upvotes: 3

Related Questions