VISUAL_BASICSHow to read RSS Feed in VB.NET?

Posts 1–3 of 3 · Page 1 of 1
How to read RSS Feed in VB.NET?
I Would like to see how to do this if anyone knows how

Please no ASP.net only VB.NET and VB.NET Components
I am also curious of this, i was reading up on a rather large PDF that explained everything last week, i'm at school so i'll see if i can give you a link when i get home.
Quote Originally Posted by xGTx View Post
I Would like to see how to do this if anyone knows how

Please no ASP.netⓘ only VB.NET and VB.NET Components
Imports System.Xml.XPath
Imports System.Data
Imports System.Data.SqlClient

Public Sub GetFeed()
Try
Dim doc As New XPathDocument(rssURL)
Dim nav As XPathNavigator = doc.CreateNavigator()
Dim iter As XPathNodeIterator = nav.Select(rssSelect)
While iter.MoveNext()
ProcessNode(iter.Current)
End While
Catch ex As Exception
Console.WriteLine(ex.Message.ToString())
End Try
End Sub

Sub ProcessNode(ByVal lstNav As XPathNavigator)
Dim title As String = ""
Dim link As String = ""
Dim description As String = ""
Dim iterNews As XPathNodeIterator = lstNav.SelectDescendants(XPathNodeType.Element, False)
While iterNews.MoveNext()
Dim rssName As String = iterNews.Current.Name
If rssName.ToUpper() = rssTitle.ToUpper() Then
title = iterNews.Current.Value
End If
If rssName.ToUpper() = rssLink.ToUpper() Then
link = iterNews.Current.Value
End If
If rssName.ToUpper() = rssDescription.ToUpper() Then
description = iterNews.Current.Value
End If
End While
If link.Length > 10 And title.Length > 10 Then
InsertNews(webNewsSourceID, link, title, description)
End If
End Sub 'ProcessNode

Sub InsertNews(ByVal webNewsSourceID As Integer, ByVal link As String, ByVal title As String, ByVal description As String)
Try
Dim objConnection As New SqlConnection
System.Configuration.ConfigurationSettings.AppSett ings("ConnectString"))
Dim objCommand As New SqlCommand("upWebNewsItem_Insert", objConnection)objCommand.CommandType = CommandType.StoredProcedure
objCommand.Parameters.Add("@WebNewsSourceID", SqlDbType.Int).Value = webNewsSourceID
objCommand.Parameters.Add("@Link", SqlDbType.VarChar, 255).Value = link
objCommand.Parameters.Add("@Title", SqlDbType.VarChar, 500).Value = title
objCommand.Parameters.Add("@ArticleDescription", SqlDbType.VarChar, 1000).Value = description
objCommand.Parameters.Add("@ID", SqlDbType.Int)
objCommand.Parameters("@ID").Direction = ParameterDirection.Output
objConnection.Open()
objCommand.ExecuteNonQuery()
objConnection.Close()
Catch ex As Exception
Console.WriteLine(("ERROR:" + ex.Message.ToString()))
End Try
End Sub
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Talk with us