Help with RSS
Hi all
I want to know how it would be possible to set up a rss feed on a site, and then get the information added to the new site to use on my site. For instance a new news topic.I want to build something that can take the detail of the new news post and display is in a more proper way in my site. Such as date published, topic, description and news detail of the new post in some sort of a Grid view...
Thanks in advance,
DiasparkDotNet DiasparkDotNetPosted May 11, 2009, 8:29 AM
Asp.net 3.5 provides classes like "SyndicationFeed", "SyndicationItem", etc.. under namespace "System.ServiceModel.Syndication" which can be used to generate & read RSS Feed .
For setting up a RSS feed for a particular site, u need to write code to generate RSS Feed. You can follow, given link for same:
http://www.geekpedia.com/tutorial157_Create-an-RSS-feed-using-ASP.NET-2.0.html
Similary, The feed generated & published from one site, can be consumed by other site by reading the RSS feed.
Example code for reading RSS Feeds:
using (XmlReader reader = XmlReader.Create(_sourceURL)
{
SyndicationFeedFormatter formatter = null;
Atom10FeedFormatter atom = new Atom10FeedFormatter();
Rss20FeedFormatter rss = new Rss20FeedFormatter();
SyndicationFeed feed;
// Determine the format of the feed
if (reader.ReadState == ReadState.Initial)
{
reader.MoveToContent();
}
if (atom.CanRead(reader))
{
formatter = atom;
}
if (rss.CanRead(reader))
{
formatter = rss;
}
if (formatter == null)
{
//return "The feed format is not supported";
}
formatter.ReadFrom(reader);
feed = formatter.Feed;
}