1

我能找到的唯一一篇文章是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
4

1 回答 1

3

.NET 有一个用于处理 RSS 提要的内置类,称为SyndicationFeed

您可以将此类用作编写自己的解析逻辑的替代方法。

于 2012-08-13T18:33:38.460 回答