Thursday, August 28, 2008

RSS/ATOM feed extensions made easy

The easiest way to add custom elements to a syndicated (ATOM/RSS feed) is to use an XElement, like this:

SyndicationFeed feed = new SyndicationFeed("FeedName", "Feed description");

//fill feed with items (omitted)

XNamespace ns = "http://tempuri.org/myapp";

feed.ElementExtensions.Add(new XElement(ns + "myCustomProperty", "hello"));

return new Atom10FeedFormatter(feed) // to return as an atom feed


Happy feeding!

No comments: