Tag Archives: RSS

Generate RSS Feed in MVC4 using VB.NET

Here is a simple function to generate the RSS feeds.
This article assumes that you are using MVC4 project with Entity Framework. Just iterate through

the relevant table to pick your data which you want to show in the RSS feed.

Remember to add the following import statements at the top of your controller
Imports System.Xml
Imports System.IO

In your controller create a function as shown below. There is no need to create a corresponding View for it

as the function will write to the RESPONSE and the XML output will be provided by the XMLTextWriter.

Function RSSNewArticles() As Action

Response.Clear()
Response.ContentType = “text/xml”
Dim objX As New XmlTextWriter(Response.OutputStream, Encoding.UTF8)
objX.WriteStartDocument()
objX.WriteStartElement(“rss”)
objX.WriteAttributeString(“version”, “2.0”)
objX.WriteStartElement(“channel”)
objX.WriteElementString(“title”, “MyWebsite.com RSS Feed“)
objX.WriteElementString(“link”, “http://mywebsite.com“)
objX.WriteElementString(“description”, “My website New Articles Feed“)
‘ objX.WriteElementString(“copyright”, “(c) 2014, best-answer.net“)
objX.WriteElementString(“ttl”, “10”)

‘Populate record for the RSS feed

For Each item In db.MyDataTable
objX.WriteStartElement(“item”)
objX.WriteElementString(“title”, item.CatName)
objX.WriteElementString(“link”, “http://mywebsite/” & item.RecordID & “/” & item.TitleName)
objX.WriteElementString(“pubDate”, Now)
objX.WriteEndElement()
Next

objX.WriteEndElement()
objX.WriteEndElement()
objX.WriteEndDocument()
objX.Flush()
objX.Close()
Response.End()
End Function

How to limit the number of RSS feed items in WordPress

This is how to change the number of RSS Feed Items in WordPress. WordPress automatically create RSS feed of your recent posts and it is located at  /feed folder.

eg. http://best-answer.net/feed/

 

In the Admin menu  go to  Settings > Reading.

LimitRSSFeedItemsinWordPress

 

 

The default might be at 14 . You can reduce or increase the number of items you want to show or expose through your RSS feed.