Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

i want to read RSS feed from a web site like :"http://www.petra.gov.jo/library/RSS/RSS_Local.xml?ID=635281437773721076[^]"
by saving it in XML file locally then i will read data from XML file to my internal database in order to use it in intranet portal

please help me to do it a simple way

Thanks
Posted
Comments
Mehdi Gholam 17-Feb-14 1:58am    
... and where are you stuck?
Sarah MQ 17-Feb-14 2:05am    
ds.ReadXml("C:\RSSreader1\RSSfeed.xml")

connection.Open()
For i = 0 To Convert.ToInt32(ds.Tables(0).Rows.Count - 1)

title = ds.Tables(0).Rows(i).ItemArray(0)
pubDate = ds.Tables(0).Rows(i).ItemArray(1)
Content = ds.Tables(0).Rows(i).ItemArray(2)

sql = "insert into AllNews (Title,NewDate,Content) Values('" & title & "','" & pubDate & "','" & Content & "')"
command = New SqlCommand(sql, connection)

Dim adapter1 As New SqlDataAdapter
adapter1.InsertCommand = command
adapter1.InsertCommand.ExecuteNonQuery()
Next

Error message :"Index was outside the bounds of the array"
i cant read nodes in XML file correctly
Ahmed Bensaid 17-Feb-14 10:27am    
Can we see your RSSfeed.xml file ?

1 solution

thanks all

i have solve my problem with this class in vb.net

VB
Imports System.Net
Imports System.Xml
Imports System.Data.SqlClient
Imports System.Data
Module Main
    Dim sql As String
    Dim connetionString As String
    Dim connection As SqlConnection
    Dim command As SqlCommand
    Dim adpter As New SqlDataAdapter
    Dim ds As New DataSet
    Dim xmlFile As XmlReader
    Dim doc As New XmlDocument()
    Sub Main()

        'This will execute when your application

        'starts up. This is the equivilent of a
        'Form_Load event in a form application.

        'Put whatever code you want in this sub,

        'but make sure you end it with this statement:
        Try
            connetionString = "Data Source=.;Initial Catalog=Newsfeed;Integrated Security=True"
            connection = New SqlConnection(connetionString)
            connection.Open()
            deletedata()
            Dim ArticleTitle As String
            Dim ArticleDate As String
            Dim ArticleText As String

            Dim RssData As New DataSet
            Dim pry As System.Net.WebProxy = New System.Net.WebProxy("x.x.x.x", 8080)
            pry.Credentials = CredentialCache.DefaultCredentials

            GlobalProxySelection.Select = pry


            RssData.ReadXml("http://www.petra.gov.jo/library/RSS/RSS_General.xml?ID=635283116713881076")

            For Each RssRow As DataRow In RssData.Tables("item").Rows
                ArticleTitle = RssRow.Item("title").ToString
                ArticleDate = RssRow.Item("pubDate").ToString
                ArticleText = RssRow.Item("description").ToString
                sql = "insert into AllNews (Title,NewDate,Content,Catalog) Values('" & ArticleTitle & "','" & ArticleDate & "','" & ArticleText & "','اخبار عالمية')"
                command = New SqlCommand(sql, connection)
                adpter.InsertCommand = command
                adpter.InsertCommand.ExecuteNonQuery()
            Next

            connection.Close()
        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

        Application.Run()

    End Sub
    Sub deletedata()
        connetionString = "Data Source=.;Initial Catalog=Newsfeed;Integrated Security=True"
        connection = New SqlConnection(connetionString)
        connection.Open()
        sql = "DELETE FROM AllNews"
        command = New SqlCommand(sql, connection)
        adpter.InsertCommand = command
        adpter.InsertCommand.ExecuteNonQuery()
    End Sub
End Module
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900