【发布时间】:2011-03-25 11:25:25
【问题描述】:
我正在使用转发器控件使用 RSS 提要显示在我的网站上。我想知道在 VB 中是否可以从我的 linq 查询中返回匿名类型,而不是强类型 RSSItems 的集合。我知道这在 C# 中是可能的,但是无法计算出 VB 等价物。
Public Class RSSItem
Public Property Title As String
Public Property Link As String
Public Property Content As String
Public Property Description As String
Public Property pubDate As String
Public Property category As String
End Class
Dim feedXML As XDocument = XDocument.Load("http://myrssfeed.com/rss.xml")
Dim xns As XNamespace = "http://purl.org/rss/1.0/modules/content/"
Dim feeds = From feed In feedXML.Descendants("item") _
Select New RSSItem With _
{.Title = feed.Element("title"),
.Link = feed.Element("link"),
.Content = feed.Element(xns.GetName("encoded")).Value,
.Description = feed.Element("description"),
.pubDate = feed.Element("pubDate"),
.category = GetCategories(feed.Elements("category"))}
【问题讨论】: