Copyrights @ Journal 2014 - Designed By Templateism - SEO Plugin by MyBloggerLab

Tuesday, August 31, 2004

Using Atom.Net feed in ASP.Net

Share
There was something really cool and simple I found on blogger site, you can use SourceForge snippet to pull any Atom Enabled RSS feeds and display on your website.

I am using this for display on my default page. You might want to pull some Atom Enabled services to your website from ->. Here is a small code piece I am using to say how easy it is to get in your website. If you do not have .Net Enabled server, use this link to find out more about your way of coding Atom Feed.

Code Lines:

Imports Atom.Core
..........
Private Sub Page_Load(ByVal sender As System.Object,
    ByVal e As System.EventArgs)
                                Handles
MyBase.Load

     If Not Page.IsPostBack Then
         lblLatestPosts.Text = getLatestPostings(0, 4)
     End
If

End
Sub

'///////////////////////////////////////////////////////
'    Function that gets the contents from Atoms Feed.
'///////////////////////////////////////////////////////
Function getLatestPostings(Optional ByVal iStart As Integer = 0,
                           Optional ByVal iEnd As Integer = 2)

Dim i As Integer
Dim
strFeed As String
Dim
myFeed As AtomFeed = AtomFeed.Load(Server.MapPath("/blog/atom.xml"))

For
i = iStart To iEnd
strFeed = strFeed & myfeed.Entries.Item(i).Issued.DateTime & _
             Environment.NewLine
strFeed = strFeed & strLatestPostStart & "<a href=""" & _
myfeed.Entries.Item(i).Links.Item(1).HRef.ToString & """>" &
_myfeed.Entries.Item(i).Title.Content & _
"</a>" & Environment.NewLine

'You may want to fetch post content also from the feed.
'strFeed = strFeed & myfeed.Entries.Item(i).summary.content.ToString()& Environment.NewLine
                       
strFeed = strFeed & strLatestPostStart & "&nbsp;" & Environment.NewLine & _
            strLatestPostEnd
Next
myFeed=Nothing
Return
strFeed
End Function

0 comments: