我能找到的唯一一篇文章是Consuming RSS 1.0 (RDF) Feeds in ASP.NET MVC 3。它使用 LINQ。反正有没有使用 lambda 表达式来做到这一点?有没有更好的方式在 MVC3 中消费和 RSS 提要?
这是我的代码:
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