Binding an RSS Feed with an XmlDataSource

I'm sure this has been blogged on a zillion times before, but this is super easy.  Look!

image

Here is the code as text (so you can copy and paste :)

<asp:XmlDataSource ID="xmlRSS"            
    DataFile="http://www.asp.net/community/articles/rss.ashx"
    EnableCaching="true"
    CacheDuration="3600"           
    XPath="rss/channel/item"
    runat="server"/>
<asp:Repeater ID="rptRSS" runat="server" DataSourceID="xmlRSS">
    <ItemTemplate>
        <p>
            <a href='<%#XPath("link")%>' target="_blank"><%#XPath("title")%></a>
        </p>
    </ItemTemplate>       
</asp:Repeater>

 

More later - j.

Published Wednesday, January 07, 2009 4:29 PM by joelvarty

Comments

# re: Binding an RSS Feed with an XmlDataSource

Thursday, April 02, 2009 3:54 PM by Chris

Why doesn't www.bungie.net/.../halo3rss.ashx work with your example as shown below? I get a blank result.

<asp:XmlDataSource ID="xmlRSS"            

   DataFile="www.bungie.net/.../halo3rss.ashx

   EnableCaching="true"

   CacheDuration="3600"          

   XPath="rss/channel/item"

   runat="server"/>

   <asp:Repeater ID="rptRSS" runat="server" DataSourceID="xmlRSS">

   <ItemTemplate>

       <p>

           <a href='<%#XPath("link")%>' target="_blank"><%#XPath("title")%></a>

       </p>

   </ItemTemplate>      

   </asp:Repeater>

Leave a Comment

(required) 
(required) 
(optional)
(required)