给定在XMLDataSource中使用的标准RSS提要,过滤RSS提要以仅显示RSS提要条目描述包含特定术语的条目的最佳方式是什么?
例如,我希望过滤下面的RSS提要,其中描述包含某个球队名称,例如“利物浦”。
http://pipes.yahoo.com/pipes/pipe.run?_id=9dae054b43e8ded5a10a659c39c72f49&_render=rss
我设置XML数据源的代码如下所示:
HomeDataSource.DataFile = "http://pipes.yahoo.com/pipes/pipe.run?_id=9dae054b43e8ded5a10a659c39c72f49&_render=rss";
HomeDataSource.XPath = "rss/channel/item";
HomeListView.DataSourceID = "HomeDataSource";
HomeListView.DataBind();使用以下源代码显示上述代码的输出:
<asp:ListView ID="HomeListView" runat="server">
<LayoutTemplate>
<ul>
<asp:PlaceHolder ID="itemPlaceHolder" runat="server"></asp:PlaceHolder>
</ul>
</LayoutTemplate>
<ItemTemplate>
<li><a target="_blank" href="<%#XPath("link")%>">
<%#XPath("title")%></a>
</li>
</ItemTemplate>
</asp:ListView>非常感谢您提供的任何建议。
发布于 2011-01-10 06:25:50
您将面临的问题是不同的提要类型,Atom、RSS1.0/2.0等,对某些公共字段使用不同的名称。您可以创建自定义DataSource控件以公开用于绑定的System.ServiceModel.Syndication SyndicationFeed对象,或者在后台代码中读取提要,并将SyndicationFeed或SyndicationFeed.Items绑定为ListViews DataSource。
https://stackoverflow.com/questions/4640443
复制相似问题