2011-01-09 84 views
1

鑑於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> 

非常感謝您提供的任何建議。

回答

0

你將面臨的問題是不同的飼料類型,原子,RSS 1.0/2.0等,使用不同的名稱爲某些共同的領域。您可以創建一個自定義DataSource控件來公開一個System.ServiceModel.Syndication SyndicationFeed對象進行綁定,或者讀取後面代碼中的提要,並將SyndicationFeed或SyndicationFeed.Items作爲ListViews DataSource綁定。