Hello,

I'm playing with some RSS functions, and I like to fetch/extract the (image:thumbnail) url from the CNN RRS Feed: http://rss.cnn.com/rss/edition.rss

In this (and other) RSS feeds there can be mediafiles (image:thumbnail) that seems to be impossible to grab and display together with the rest of the feed output. The <image> tag maight be an extenstion unknown to System.ServiceModel.Syndication, but it must be possible to fetch it some way...? And I like to use the <Image> Url for the image tag below.

Please don't suggest "google that" or something, I have already done that for a few days now...

.aspx page

<asp:DataList ID="DataList1" runat="server" CellPadding="6" ForeColor="#333333" Width="100%">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingItemStyle BackColor="White" ForeColor="#284775" />
<ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<ItemTemplate>

<asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Eval("Title.Text") %>' Font-Bold="True" NavigateUrl='<%# Eval("Links[0].Uri.AbsoluteUri") %>'></asp:HyperLink>
<br />
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Summary.Text") %>'></asp:Label>
<br />
<asp:Label ID="Label2" runat="server" Font-Bold="True" Text='<%# Eval("PublishDate.DateTime","Published On :{0}") %>'></asp:Label>
<br />
<asp:Image ID="Thumbnail" runat="server" ImageUrl=""></asp:Image>

</ItemTemplate>
</asp:DataList>

Codebehind:

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
using System.Xml.XPath;
using System.ServiceModel.Web;
using System.ServiceModel.Syndication;
using System.Text;

namespace rssnews
{
    public partial class _default : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            getRSS();
        }

        private void getRSS()
        {
            XmlReader reader = XmlReader.Create("http://rss.cnn.com/rss/edition.rss");
            Rss20FeedFormatter formatter = new Rss20FeedFormatter();
            formatter.ReadFrom(reader);
            reader.Close();

            Label3.Text = formatter.Feed.Title.Text;
            Label5.Text = formatter.Feed.Copyright.Text;

            DataList1.DataSource = formatter.Feed.Items;
            DataList1.DataBind();
        }





    }
}

Recommended Answers

All 2 Replies

HI,

The Rss20FeedFormatter just ignore other tags than the RSS standard... Atleast it appear that way :-(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.