Reading RSS/XML Feed with Asp.net

Imports System.Data
Imports System.Xml
Partial Class rss_rss
    Inherits System.Web.UI.UserControl 

    Public Function ReadRss(ByVal url As String) As String

        Dim rss As New XmlTextReader(url)
        Dim dt As New DataSet
        Dim Title As String
        Dim link As String

        Try


            dt.ReadXml(rss)


            For Each item As DataRow In dt.Tables(2).Rows
                Title = item("title") & ""
                link = item("link") & ""
                output.Text += "<a href='" & link & "' target='blank'>" & Title & "</a> <font color='#C0C0C0'>-</font> "

             ' output is a control on my webpage  


            Next

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try 

    End Function

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Call Me.ReadRss("url here")
        Call Me.ReadRss("url here")
    End Sub
End Class
 

Posted by:

Comments History


by: on
By the way if you do not want to output to a control, then you can easily connect the output to a asp repeater or any any other control. Simply do Data Binding on it. repeater.Datasource = dt.tables(0) reapeater.DataBind()
 

Name :  

Email :  

Comment Below