creating Rss using xml

infernocy

New member
Joined
Mar 16, 2012
Messages
1
Programming Experience
Beginner
i have the following code of rss feed on vb.net a friend help me to build it
Imports System.Data.OleDb
Imports System.Xml
Imports System.servicemodel.syndication


Partial Public Class RSS

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.ContentType = "application/rss+xml"

Dim myFeed As New SyndicationFeed
myFeed.Title = TextSyndicationContent.CreatePlaintextContent(" New images on Tulips")
myFeed.Description = TextSyndicationContent.CreatePlaintextContent _
("The most recent articles added ")
myFeed.Links.Add(SyndicationLink.CreateSelfLink _
(New Uri(function1("list.aspx"))))
myFeed.Language = "en.us"

Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
oleDbConn.Open()
Dim cmdQuery As String = "SELECT TOP 10 * from Photo"
Dim dbcomm = New OleDbCommand(cmdQuery, oleDbConn)
Dim dbread = dbcomm.ExecuteReader()
Dim myItems As New List(Of SyndicationItem)
While dbread.Read()
Dim sItem As New SyndicationItem
sItem.Title = mkRssText(dbread("Photo_Title"))
sItem.Summary = mkRssText(dbread("Photo_Category") & dbread("Photo_Description"))



myItems.Add(sItem)

End While

myFeed.Items = myItems


Dim feedwriter As XmlWriter = XmlWriter.Create(Response.OutputStream)
Dim rssFormatter = New Rss20FeedFormatter(myFeed)
rssFormatter.WriteTo(feedwriter)
feedwriter.Close()






End Sub
Private Function mkRsslink(ByVal someLocation As String) As SyndicationLink
Return SyndicationLink.CreateAlternateLink(New Uri(someLocation))

End Function



Private Function function1(ByVal urlstr As String)
Return Request.Url.GetLeftPart(UriPartial.Authority) & ResolveUrl(urlstr)
End Function

Private Function mkRssText(ByVal someString As String) As TextSyndicationContent
Return TextSyndicationContent.CreatePlaintextContent(someString)

End Function


i want to know if this is consider as exporting the data as rss feed
also i want to create a link to the main page in the begging in the vb.net code

thanks for the help


End Class
 
Last edited:
Back
Top