Ok. yesterday i said i would post some code for RSSAgg, and here it is. Im only going to post some little bits because im lazy, but they are the important parts so here it goes:
Firstly theres a function which does all the hard work. this gets data from the RSS Feeds and returns a dataset to the sub that called the functions:
Public Function getdata() As DataSet
Dim myDS As New DataSet ' the dataset
Dim rsstable As New DataTable ' datatable that gets imported into the dataset
Dim datecol As New DataColumn("Date") ' the date colum.
datecol.DataType = System.Type.GetType("System.DateTime") ' set the type of data in the date colum to datetime
rsstable.Columns.Add(datecol) ' add the date column to the table
rsstable.Columns.Add(New DataColumn("Title")) ' add a new title colum to the table
rsstable.Columns.Add(New DataColumn("description")) ' add a new title colum to the table
rsstable.Columns.Add(New DataColumn("link")) ' add a new title colum to the table
rsstable.Columns.Add(New DataColumn("channel")) ' add a new title colum to the table
rsstable.Columns.Add(New DataColumn("chanurl")) ' add a new title colum to the table
Dim array As New ArrayList 'array of sites your to connect to
array.Add("http://feeds.feedburner.com/blogspot/hnKu") ' links blog
array.Add("http://blog.lotas-smartman.net/feed/") ' main blog
array.Add("http://weblogs.asp.net/tiernanotoole/Rss.aspx") ' dev blog
Dim x As Integer ' counter
For x = 0 To array.Count - 1
Dim feed As Rss.RssFeed = Rss.RssFeed.Read(array(x))
Dim channel As Rss.RssChannel = feed.Channels(0)
Dim i As Integer
For i = 0 To channel.Items.Count - 1
Dim myrow As DataRow
myrow = rsstable.NewRow
Dim item As New Rss.RssItem
item = channel.Items(i)
Dim mydate As Date
mydate = item.PubDate
myrow("Date") = mydate
myrow("Title") = item.Title
myrow("description") = item.Description
myrow("link") = item.Link
myrow("chanurl") = feed.Channels(0).Link
myrow("channel") = feed.Channels(0).Title
rsstable.Rows.Add(myrow)
rsstable.AcceptChanges()
Next
Next
myDS.Merge(rsstable)
Return myDS
End Function
As you can see, i kind of got board with the comments after a while. Now, then you have the page load sub:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cached As String = ""
Dim ds As DataSet = Cache("RSSds")
If Not ds Is Nothing Then
cached = "Dataset cached"
Else
Dim ws As New rssAgg.RSSAggWS
cached = "Dataset not cached"
ds = getdata()
Cache.Add("RSSds", ds, Nothing, DateTime.Now.AddMinutes(30), TimeSpan.Zero, Caching.CacheItemPriority.Normal, Nothing)
End If
ds.Tables(0).DefaultView.Sort = "date desc"
Repeater1.DataSource = ds.Tables(0).DefaultView
Repeater1.DataBind()
End Sub
the variable "cached" used to be written out to show you if it was cached or not. now. some important things that are needed. Firstly you need RSS.NET. Not only that but you need to modified the code because of a date time problem with it. the info is in Bug 927898. i put in the code and it works grand now. currently its only parsing RSS2.0, or mainly RSS2.0 feeds, but RSS.net will do other RSS Feeds too. i might work on atom support, but not for a while now. Next task: SQL server for the back. the plan is to query the feeds every 15 or 30min and put the data into a SQL Server. then when the page is loaded, the page queries the DB and recives only the last 10 or 20 results. we will see later though! That could be a 0.2 alpha release. i might have an RSS feed for RSSAgg in at 0.15? keep checking back!