Click here to check my latest exciting videos on youtube
Search Mallstuffs

Flag Counter
Spirituality, Knowledge and Entertainment


Locations of visitors to this page


Latest Articles


Move to top
Why and how to create RSS feeds in C#
Posted By Sarin on May 04, 2013     RSS Feeds     Latest Hinduism news
7308 Views

RSS stands for Rich Site Summary. RSS is the format of delivering new articles updates to your visitors. RSS is mostly used by Blogging sites, news sites, and similar other publishers that wanna display all their new articles in one go as an RSS Feed.
  
Why RSS feeds?
Every user visits hundreds of websites every day. Now such user doesn’t have the time to visit the site they like every day. Such users are interested in visiting your site only when your website is updated with new articles. RSS comes as a rescue for all such visitors as it allow them to stay informed about the latest content in the sites they are interested in. Newsletter and site email also achieves this purpose but most of the visitors expect privacy and are not interested in sharing their email for weekly or daily newsletters.  
  
How to read an RSS Feed?  
Feed Reader or News Aggregator allows users to read feeds from multiple websites. Instead of visiting hundreds of different sites, users use this software to check for updates from all websites in a single screen. This helps them in saving their time effectively. Some of the most popular feed readers are FeedReader <https://www.feedreader.com/>  (Windows), Amphetadesk <https://www.disobey.com/amphetadesk/>   (Windows, Linux, Mac), NetNewsWire <https://www.newsgator.com/Individuals/NetNewsWire/Default.aspx> (Mac) , Rol <https://www.rss-readers.org/download/rol-rss-reader-for-linux/> (Linux). NewsGator <https://www.newsgator.com/>   (Windows+Outlook) Feed Demon <https://www.feeddemon.com/> (Windows) Google Reader <https://www.google.com/reader/>   and Newz Crawler <https://www.newzcrawler.com/>   

What RSS feed offer for website owners
Once you have created your RSS feeds, submit it to various RSS submission sites. There are hundreds of RSS submissions out there which will return you thousand of unique visitors. This RSS feeds also acts as back links that increases the page rank of your website
Sample RSS feed
This is how the sample RSS Xml file looks like. This RSS file is for two articles. First few tags(title, description, link, language, lastBuildDate) contains the information of RSS feed. Next is the list of articles enclosed in item tag. For each article, there is an item tag.

Why and how to create RSS feeds in C#
  
How to create RSS feeds in .Net
Use the following code to create an RSS feeds in .Net

XElement rss = new XElement("rss", new XAttribute("version", "2.0"));
XDocument myXml = new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
                                new XComment(SearchType + "Articles RSS"),rss);
myXml.Element("rss").Element("channel").Add(new XElement("title", "Published Technical Articles"));
myXml.Element("rss").Element("channel").Add(new XElement("description", "Get Informed of  all the latest Technical Articles"));
myXml.Element("rss").Element("channel").Add(new XElement("link", "https://www.mallstuffs.com/Blogs/Blogs.aspx?BlogtypeId=2"));
myXml.Element("rss").Element("channel").Add(new XElement("language", "en-us"));
myXml.Element("rss").Element("channel").Add(new XElement("lastBuildDate", DateTime.UtcNow));
DataTable dt = DBManager.QueryResult("select top 10 * from blogs where blogtypeid=2 order  by CreatedDate desc");
      foreach (DataRow dr in dt.Rows)
                     {
      myXml.Element("rss").Element("channel").Add(new XElement("item", new XElement("title", dr["Topic"].ToString()), new XElement("link", "https://www.mallstuffs.com/Blogs/BlogDetails.aspx?BlogId=" + dr["BlogId"].ToString() + "&BlogType=" + SearchType + "&Topic=" + dr["Topic"].ToString()), new XElement("pubDate", dr["CreatedDate"].ToString()), new XElement("description", dr["Summary"].ToString())));
                    }
using (StreamWriter streamWriter = new StreamWriter(xmlPath))
                 {
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;
                    using (XmlWriter writer = XmlWriter.Create(streamWriter, settings))
                     {
                        myXml.WriteTo(writer);
                    }
                }
Just replace the Data retrieval code by your own code which kind of depends upon how your application interacts with the database. I have added my own custom logic to create the RSS contents for my articles. Check the below link for the created RSS feed.  
<https://mallstuffs.com/settings/TechnicalBlog.xml>
This will help you in understanding the above code.
Conclusion:
In this article, we saw why RSS feeds are very important for blogging and news sites. We saw how to view and create RSS feeds. RSS feeds help you in attracting more visitors to your site and also in increasing the page rank of your website.



Note: Images used on this website are either a production of Bhaktivedanta Book Trust(https://www.krishna.com), Iskcon Foundation or were found in google search under "Free to use and share". If any of the images presented here violates copyright issues or infringes anyone copyright or are not under "Fair use", then please bring it to our notice. Read Disclaimer for more.

Share this to your friends. One of your friend is waiting for your share.
Related Articles
Visitors-Hits counter for your website
Why and how to create RSS feeds in C#

Post Comment