Using(var writer = XmlWriter.Create(output, To close this post, let’s push it out as a formatted XML string to the console: var output = new StringBuilder() Or for an Atom feed, this: SyndicationFeedFormatter formatter =Īt this point, you have a streamable XML object, so you can send it to an MVC Return type, an XML Output stream, a Linq to XML query, and all sorts of other things. To format it as an Rss version 2 feed, use the following: SyndicationFeedFormatter formatter = NewFeed.Items = articles.Select(article => NewFeed.LastUpdatedTime = DateTime.UtcNow ĬreatePlaintextContent("My Article Feed") Once you have some data, you can easily construct the feed by using the following code: var newFeed = new SyndicationFeed() We can produce a feed similar to this blog’s, by using the formatter in the reverse direction.įirst, let’s create some data to add to the feed. Let’s imagine we have the following object definition: public class ArticleSummary Reading them is one thing, but the syndication classes also can be used to produce RSS feed data just as easily. You could, for example, in the case of an internal notification system, decide to show items with an “Urgent” tag immediately. If the feed specifies it, each item also has a list of authors, tags, and various other bits of meta information that could be used to decide how to present an item. It’s up to you how you deal with it, but you can see just how easy it is to grab the XML from a feed, pass it to the Rss Version 2 formatter, and then iterate over the collection of items available. When added to a console mode program, the output looks like this: Var title = įoreach (var syndicationItem in ) We can easily read this and display its contents by using the following code. The RSS feed for this blog can be found at. NET has built-in classes for creating syndication feeds, and these can be found in the “” namespace. What many folks don’t know, however, is that. (I often don’t hear it because I have headphones on.) I have a similar setup on the PC I’m writing this on. ![]() this-plug in monitors an XML end point on a central Windows service, and when there’s a short message to send out to all staff, it’s sent to this service, which sends it out as an RSS feed, which is then rendered in the user’s browser. A custom plug-in has been written for the Chrome browser all his staff use. I have a client that uses them for workplace notifications. The fact is that XML-based RSS & Atom feeds are still used in quite a lot of places, and although they may not be as popular as they once were, they do still have their uses. ![]() Even this blog you’re reading now has an RSS feed if you look at the. Your browser, too, has an RSS Feed reader built into it, and let’s not forget many of the Google APIs, such as the YouTube search API, that returns its results as an Atom feed, which is a newer type of the original RSS Protocol. I’m willing to bet the answer is “Not Many”, but the reality is, you use it without realizing.ĭoes it run on WordPress? Well, take a close look at it, then, because it’ll be using RSS.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |