Generating a valid RSS feed using SyndicationFeed and Rss20FeedFormatter

If you are using the .NET Rss20FeedFormatter and SyndicationFeed classes to generate an RSS feed, you may run into an issue of needing to include a link attribute to the channel element.  If you validate the default RSS generated the validation will fail since the channel element does not contain a link attribute.

You can test this by going to http://beta.feedvalidator.org and entering your feed Url.  If you recieve the error

Missing channel element: link

you can modify your code as follows:

 

SyndicationFeed syndicationFeed = new SyndicationFeed(synicationItems);
syndicationFeed.AttributeExtensions.Add(new XmlQualifiedName("link"), "http://yoursite.com");

 

This will produce a valid RSS feed with a channel that contains a link attribute.

Comments are closed