Click here to Skip to main content
15,888,018 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB.NET
Imports System.Xml
Imports System.Xml.XPath

Public Class FormRSS

    Private mRssUrl As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        mRssUrl = String.Empty

    End Sub

    Private Sub tsRssGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsRssGo.Click

                'Set RSS Feed URL
                mRssUrl = "http://news.google.co.kr/news?pz=1&cf=all&ned=kr&hl=ko&output=rss"
                'ListView Clear
                tvwRss.Nodes.Clear()
                'Create New XMLDocument Variable
                Dim doc As New XmlDocument()
                Try
                    'Load RSS from RSS URL
                    doc.Load(mRssUrl)
                Catch ex1 As Exception
                    'Showin Error Msg
                    MessageBox.Show(ex1.Message)
                    Return
                End Try
                Dim navigator As XPathNavigator = doc.CreateNavigator()
                Try
                    'Get Post Title form RSS
                    Dim nodes As XPathNodeIterator = navigator.Select("/rss/channel/item/title")
                    While nodes.MoveNext
                        Dim node As XPathNavigator = nodes.Current
                        Dim tmp As String = node.Value.Trim()
                        tmp = tmp.Replace(ControlChars.CrLf, "")
                        tmp = tmp.Replace(ControlChars.Lf, "")
                        tmp = tmp.Replace(ControlChars.Cr, "")
                        tmp = tmp.Replace(ControlChars.FormFeed, "")
                        tmp = tmp.Replace(ControlChars.NewLine, "")
                        'Post Title add to ListView
                        tvwRss.Nodes.Add(tmp)
                    End While
                    Dim position As Integer = 0
                    ' Get the links from the RSS feed
                    Dim nodesLink As XPathNodeIterator = navigator.Select("/rss/channel/item/link")
                    While nodesLink.MoveNext
                        Dim node As XPathNavigator = nodesLink.Current
                        Dim tmp As String = node.Value.Trim()
                        tmp = tmp.Replace(ControlChars.CrLf, "")
                        tmp = tmp.Replace(ControlChars.Lf, "")
                        tmp = tmp.Replace(ControlChars.Cr, "")
                        tmp = tmp.Replace(ControlChars.FormFeed, "")
                        tmp = tmp.Replace(ControlChars.NewLine, "")
                        ' Child Node Add to Parent Nodes
                        tvwRss.Nodes(position).Nodes.Add(tmp)
                        PostBody(position) = tmp   '<----   System.NullReferenceException   Error!!!
                        position += 1
                    End While
                Catch ex As Exception
                    MessageBox.Show(ex.Message, "Load Fail")
                End Try
            Catch ex2 As Exception
                MessageBox.Show(ex2.ToString(), "Initialization Fail")
            End Try
        End If
    End Sub


This is Part of an RSS reader code.

In the code above, `PostBody (position) = tmp` Error in part.

What the hell is wrong with it?

I do not know. :confused: help
Posted
Updated 21-May-10 3:44am
v3
Comments
Wayne Gaylard 21-May-10 9:46am    
What is PostBody, is it a custom method or is it part of .Net. I cannot find any references to it.

1 solution

It's telling you that PostBody is null. I assume it's meant to be an iterator or that the item at PostBody(position) is null - in other words, you haven't created an instance at this position. Try
PostBody(position) = New whatever this is meant to represent here.
 
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