0

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();
        }





    }
}

Edited by TobbeK: Fixed markdown.

2
Contributors
2
Replies
16
Views
2 Years
Discussion Span
Last Post by TobbeK
0

HI,

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.