RSS Feed XMLDataSource过滤RSS项目
问题描述:
鉴于XMLDataSource中正在使用标准RSS订阅源,过滤RSS订阅源以仅显示RSS订阅项目说明包含特定术语的项目的最佳方法是什么?RSS Feed XMLDataSource过滤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>
非常感谢您提供的任何建议。
答
你将面临的问题是不同的饲料类型,原子,RSS 1.0/2.0等,使用不同的名称为某些共同的领域。您可以创建一个自定义DataSource控件来公开一个System.ServiceModel.Syndication SyndicationFeed对象进行绑定,或者读取后面代码中的提要,并将SyndicationFeed或SyndicationFeed.Items作为ListViews DataSource绑定。