Results 1 to 8 of 8

Thread: Can't get RSS Feed (XML)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    Can't get RSS Feed (XML)

    Hi All,

    Im playing around with getting RSS feed data (XML of course) so I can stay up to date.

    I have read countless google results about getting it either straight into XMLreader (would be nice) or otherwise.

    Every time I tried doing it the reader would tell me that hexadecimal value xxxx is invalid and die.

    I decided to try and get the data to see whats going on and its all garbage I don't know why I cant get the XML.

    If you grab the link and paste into a browser it shows the XML just fine.

    The code I have to just look at it is

    Code:
    Dim t As String = "https://kat.cr/usearch/the%20flash%20category%3Atv%20user%3Aettv%20verified%3A1/?rss=1"
    Dim wc As New WebClient
    Dim j As String = wc.DownloadString(t)
    TextBox1.Text = j
    Now instead of returning a nice page of XML I get all sorts of random data like below. Im not sure whats going on but I have tried adding headers, using requests instead of webclient, all come out the same. I know its possible, if you head to any online XML validation service they can load and parse it just fine. I just don't know where im going wrong.

    Name:  feed.jpg
Views: 277
Size:  40.1 KB
    My CodeBank Submissions
    • Listbox with transparency and picture support - Click Here
    • Check for a true internet connection - Click Here
    • Open Cash drawer connected to receipt printer - Click Here
    • Custom color and size border around form - Click Here
    • Upload file to website without user logins, includes PHP - Click Here
    • List All Removable USB Storage Devices - Click Here
    • Custom On/Off Slide Control - Click Here
    • Insert multiple rows of data into one database table using parameters - Click Here
    • Trigger USB/Serial Cash Drawer - Click Here

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Can't get RSS Feed (XML)

    Try this:

    Code:
    Dim t As String = "https://kat.cr/usearch/the%20flash%20category%3Atv%20user%3Aettv%20verified%3A1/?rss=1"
    Dim wc As New WebClient
    Dim j As String = wc.DownloadString(t)
    TextBox1.Text = XDocument.Parse(j).ToString

  3. #3
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: Can't get RSS Feed (XML)

    It looks like it is encrypted. When I browse to the link and look at the source it looks like XML.

    paul - Tried your code and it did not work for me.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  4. #4
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: Can't get RSS Feed (XML)

    Well,

    I just tried your link using the WebBrowser control.

    VB.NET Code:
    1. webBrowser1.Navigate("https://kat.cr/usearch/the%20flash%20category%3Atv%20user%3Aettv%20verified%3A1/?rss=1")

    DocumentCompleted Event
    VB.NET Code:
    1. Private Sub webBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
    2.     Dim webBrowser As WebBrowser = CType(sender, WebBrowser)
    3.     Dim source As String = webBrowser.DocumentText
    4.     TextBox1.Text = source
    5. End Sub

    I did get the source but in HTML format/with HTML tags. The feed content is there, except that you need some sort of cleanup to extract the XML/RSS feed.

    - kgc
    Last edited by KGComputers; Jun 26th, 2016 at 01:37 PM.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  5. #5
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: Can't get RSS Feed (XML)

    It's just that it's GZip encoded.
    Code:
    Dim url As String = "https://kat.cr/usearch/the%20flash%20category%3Atv%20user%3Aettv%20verified%3A1/?rss=1"
    Dim xml As String
    
    Try
        Using wc As New WebClient
            Using wcStream As IO.Stream = wc.OpenRead(url)
                Using gzStream As New IO.Compression.GZipStream(wcStream, IO.Compression.CompressionMode.Decompress)
                    Using reader As New StreamReader(gzStream)
                        xml = reader.ReadToEnd
                    End Using
                End Using
            End Using
        End Using
    
        TextBox1.Text = xml
    
    Catch ex As Exception
        MsgBox(ex)
    End Try

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: Can't get RSS Feed (XML)

    Slightly modified version of Inferrd's code.

    Code:
            Dim url As String = "https://kat.cr/usearch/the%20flash%20category%3Atv%20user%3Aettv%20verified%3A1/?rss=1"
            Dim rssXE As XElement
    
            Try
                Using wc As New Net.WebClient
                    Using wcStream As IO.Stream = wc.OpenRead(url)
                        Using gzStream As New IO.Compression.GZipStream(wcStream, IO.Compression.CompressionMode.Decompress)
                            Using reader As New StreamReader(gzStream)
                                rssXE = XElement.Load(reader)
                            End Using
                        End Using
                    End Using
                End Using
            Catch ex As Exception
                Debug.WriteLine(ex)
            End Try
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    Re: Can't get RSS Feed (XML)

    hi all, sorry for late reply. yes it seems its just gzip encoded. thanks for all the help. that stumped me for like a whole day.

    any way to tell if something is Gzip encoded?
    My CodeBank Submissions
    • Listbox with transparency and picture support - Click Here
    • Check for a true internet connection - Click Here
    • Open Cash drawer connected to receipt printer - Click Here
    • Custom color and size border around form - Click Here
    • Upload file to website without user logins, includes PHP - Click Here
    • List All Removable USB Storage Devices - Click Here
    • Custom On/Off Slide Control - Click Here
    • Insert multiple rows of data into one database table using parameters - Click Here
    • Trigger USB/Serial Cash Drawer - Click Here

  8. #8
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: Can't get RSS Feed (XML)

    any way to tell if something is Gzip encoded?
    Using Mozilla Firebug, Go to Net Tab -> All -> Expand the URL -> Headers -> Expand the Response Headers. There's a property called Content-Encoding.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width