Display items from external RSS feed?
Our client would like to display items from an external RSS feed in the sidebar on a page of their site. Is there a control that will do this?
I stopped looking for a control and built a very simple one that uses an XMLDataSource and DataList. Works great.
+1 I would find this great out-of-the-box functionality also.
Hi,
XMLDataSource control will really be a very good choice in displaying any RSS feed in user control
ascx.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="XML.ascx.cs" Inherits="SitefinityWebApp.Custom.XML" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<
asp:XmlDataSourceID
=
"XmlDataSource1"
runat
=
"server"
>
</
asp:XmlDataSource
>
<
asp:RepeaterID
=
"Repeater1"
runat
=
"server"
DataSourceID
=
"XmlDataSource1"
>
<
ItemTemplate
>
<%#XPath("link")%>"> <%#XPath("title")%>
</
ItemTemplate
>
<
SeparatorTemplate
>
<
hr
/>
</
SeparatorTemplate
>
</
asp:Repeater
>
Code behind:
XmlDataSource1.DataFile =
"http://www.eyefootball.com/rss_news_main.xml"
;
XmlDataSource1.XPath =
"rss/channel/item"
;
XmlDataSource1.Data=
"XmlDataSource1"
;
XmlDataSource1.DataBind();
Stanislav, tnx for the details. Just tried this and it works fine. Though, for others, there were a few typos that should be addressed if you copy/paste from the post above.
<asp:XmlDataSourceID="XmlDataSource1"runat="server"> //need space between XmlDataSource and ID.
<asp:RepeaterID="Repeater1"runat="server"DataSourceID="XmlDataSource1"> //same, need space betwen Repeater and ID.
<%#XPath("link")%>"> <%#XPath("title")%> //Extra "> after the "link" xpath.
Here's similar code with slight adjustments:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="XML.ascx.cs" Inherits="SitefinityWebApp.Custom.XML" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<
asp:XmlDataSource
ID
=
"XmlDataSource1"
runat
=
"server"
></
asp:XmlDataSource
>
<
asp:Repeater
id
=
"Repeater1"
runat
=
"server"
DataSourceID
=
"XmlDataSource1"
>
<
ItemTemplate
>
<
h2
>
<%#XPath("title")%>
</
h2
>
<
strong
><%#XPath("pubDate")%> </
strong
><
br
/>
<
br
/>
<
a
href
=
"<%#XPath("
link")%>">Read Full Story >> </
a
>
</
ItemTemplate
>
<
SeparatorTemplate
>
<
hr
/>
</
SeparatorTemplate
>
</
asp:Repeater
>
Please vote for this feature request if you think 'Rss feed reader control' should be an out of the box feature in future revisions of Sitefinity.
http://feedback.telerik.com/Project/153/Feedback/Details/123666-rss-feed-reader-control
Thanks
I have used the approach the approach Stanislav Velikov mentioned, where you consume an RSS feed from Sitefinity and publish it as Sitefinity content. That approach worked very well for my needs. The key settings to look at are:
You can then schedule the import to occure daily, hourly ect. The reason I like this approach is that if the external feed goes down your site will still be able to display the already imported feeds.