我想在我的视图中输出我的 RSS 提要,如下所示:
@ModelType IEnumerable(Of MyBlog.RssModel)
<table>
<tr>
<th>
Title
</th>
<th>
Description
</th>
<th>
Link
</th>
<th></th>
</tr>
@For Each item In Model
Dim currentItem = item
@<tr>
<td>
@Html.DisplayFor(Function(modelItem) currentItem.Title)
</td>
<td>
@Html.DisplayFor(Function(modelItem) currentItem.Description)
</td>
<td>
@Html.DisplayFor(Function(modelItem) currentItem.Link)
</td>
<td>
</td>
</tr>
Next
</table>
这是我的代码:
Function ShowFeed() As ActionResult
Dim feedUrl = "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml"
Dim feed As SyndicationFeed = GetFeed(feedUrl)
Dim model As IList(Of RssModel) = New List(Of RssModel)()
For Each item As SyndicationItem In feed.Items
Dim rss As New RssModel()
rss.Title = item.Title.ToString
rss.Description = item.Summary.ToString
rss.Link = item.Links.ToString
model.Add(rss)
Next
Return View(model)
End Function
产生意想不到的结果:
标题 描述 链接
System.ServiceModel.Syndication.TextSyndicationContent
System.ServiceModel.Syndication.TextSyndicationContent
System.ServiceModel.Syndication.NullNotAllowedCollection 1[System.ServiceModel.Syndication.SyndicationLink] System.ServiceModel.Syndication.TextSyndicationContent System.ServiceModel.Syndication.TextSyndicationContent System。 ServiceModel.Syndication.NullNotAllowedCollection`1[System.ServiceModel.Syndication.SyndicationLink]1[System.ServiceModel.Syndication.SyndicationLink]
System.ServiceModel.Syndication.TextSyndicationContent
System.ServiceModel.Syndication.TextSyndicationContent
System.ServiceModel.Syndication.NullNotAllowedCollection