Go to content Go to navigation Go to search


silverlight rss feed displayer
· 2007-05-22 22:30 by Thijs Kroesbergen for Brokenwire.NET

Tonight I built a small silverlight application which reads this site’s rss feed and displays it in a “nice” format.

See SilveRSS in action!

Getting the animation done was quite simple too, but I did some fine-tuning inside the XAML code myself. Probably because I don’t know Expression Blend well enough yet.

The biggest challenge was to have the Silverlight applet decypher the rss-xml layout. But actually all that is very basic .NET programming.
The code to retrieve the rss data and parse the XML looks like this:

    Uri uri = new System.Uri("http://www.brokenwire.net/bw/rss");
    BrowserHttpWebRequest request = new BrowserHttpWebRequest(uri);
    HttpWebResponse response = request.GetResponse();
    StreamReader responseReader = new StreamReader(response.GetResponseStream());
    string rawvalue = responseReader.ReadToEnd();
    XmlReader xr = XmlReader.Create(new StringReader(rawvalue));
    while (xr.ReadToFollowing("item"))
         //RssItem is a struct to contain the data for one item
         RssItem item;
         item.title = xr.ReadElementContentAsString();
         item.description = Strip(xr.ReadElementContentAsString());
         item.link = xr.ReadElementContentAsString();
         // Add items to a list

Controlling the animations is just a matter of catching the Storyboard “Completed” events.

Other examples I found on the web are using the power of the webserver to create XAML code on the server, and displaying that on the client. But I didn’t want to and didn’t need to write any server-side code in this example.

Permalink -

  1. What namespace is Strip in or is it something your rolled yourself?

    Thanks for the example :)

    Glen    2007-09-07 16:20    #
  2. Strip() is a home-made function, simply drops all HTML tags from a piece of text…

    — thijs    2007-09-14 21:05    #
  3. can you email me all the source code to try out locally… thanks

    m lees    2007-10-17 13:32    #
  4. Hi,
    thanks for your example.
    Can you please email me all the source code ?
    I’m a beginner in Silverlight & .Net (come from Java development).



    Antwan    2009-02-02 10:49    #
  5. can u please share the code for the Strip function?

    vikram    2009-04-02 12:22    #
  6. I don’t have the original code any more, but for example:

    using System.Text.RegularExpressions;

    const string HTML_TAG_PATTERN = “<.*?>”;

    static string StripHTML (string inputString)
    { return Regex.Replace (inputString, HTML_TAG_PATTERN, string.Empty);

    thijs    2009-04-02 12:39    #
  7. I posted a full open sourde silverlight rss project on the codeproject site from Microsoft


    Peter Adriaenssens    2010-09-06 16:06    #