我正在尝试在我的页面上写一些联合,
我使用 .Net 类将 rss 内容放入列表
<div>
<%
var r = System.Xml.XmlReader.Create("http://www.huffingtonpost.com/feeds/verticals/small-business/index.xml");
System.ServiceModel.Syndication.SyndicationFeed albums = System.ServiceModel.Syndication.SyndicationFeed.Load(r);
r.Close();
foreach (System.ServiceModel.Syndication.SyndicationItem album in albums.Items)
{
Response.Write(album.Title.Text);
}
%>
</div>
好吧,foreach
这里只是作为一个forfirst,因为它只在列表中写入第一个 SyndicationItem。如您所见,该列表中有许多项目。我的错误在哪里?
只是为了确保我的专辑列表中不仅有一项,我数了一下。
<div>
<%
var r = System.Xml.XmlReader.Create("http://www.huffingtonpost.com/feeds/verticals/small-business/index.xml");
System.ServiceModel.Syndication.SyndicationFeed albums = System.ServiceModel.Syndication.SyndicationFeed.Load(r);
r.Close();
int i = albums.Items.ToList().Count;
Response.Write(i);
/* foreach (System.ServiceModel.Syndication.SyndicationItem album in albums.Items)
{
Response.Write(album.Title.Text);
} */
%>
</div>
结果: