Create a GeoRSS Feed in .NET

Last week, I was working on a small team project that leveraged ESRI’s ArcGIS Viewer for Silverlight. We wanted to plot points on the map using latitude and longitude coordinates, something that the viewer supports natively through its GeoRSS widget; all we needed to do is provide a GeoRSS feed!

The RSS feed’s just an XML document, and GeoRSS is just a specific format for an RSS feed. So, it should be no problem to do. I hadn’t created an RSS feed before, so I started by Googling. I figured I’d end up building an XML document using Linq to XML and writing the contents to a page. It was even easier than that, though. The .NET Framework has RSS classes built right in!

Here’s a very simple example of how to create a GeoRSS feed in .NET by using the Rss20FeedFormatter class:

public Rss20FeedFormatter GetItems()
    var feed = new SyndicationFeed(
        “My GeoRSS Feed”,
        “A silly little feed”,
        new Uri(“”));

    var items = GetItemsFromDataSource();
    feed.Items = items.Select(
        x =>
            var f = new SyndicationItem(x.Title, x.Description, x.Link, x.Id, DateTime.Now);
            f.PublishDate = x.PubDate;
            f.Summary = new TextSyndicationContent(x.Description);

            XNamespace geons = “”;
            var lat = new XElement(geons + “lat”, x.Latitude);
            f.ElementExtensions.Add(new SyndicationElementExtension(lat));
            var lon = new XElement(geons + “long”, x.Longitude);
            f.ElementExtensions.Add(new SyndicationElementExtension(lon));
            return f;

    return new Rss20FeedFormatter(feed);

Taking it one step further, we needed to host our feed and make it accessible via a web service call.

So, we created an interface…

public interface IRssFeed
    Rss20FeedFormatter GetItems();

And created a new WCF endpoint in our web.config (did I mention this was an ASP.NET application?)…

      <behavior name=“webHttpBehavior”>
        <webHttp />
    <service name=“”>
      <endpoint binding=“webHttpBinding”
				contract=“” />

And voila–we were done! Browsing to “http://ourserver/ourapplication/MyItemsFeed/GetItems&#8221; gave us our valid GeoRSS feed, and we fed that to our ArcGIS Viewer to plot the points. It all worked swimmingly!

Author: Adam Prescott

I'm enthusiastic and passionate about creating intuitive, great-looking software. I strive to find the simplest solutions to complex problems, and I embrace agile principles and test-driven development.

2 thoughts on “Create a GeoRSS Feed in .NET”

Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: