A
Anonymous
Hello,
I am loading a simple rss file via the XmlTextReader
and getting the following error:
Object reference not set to an instance of an object.
Here is the code which I use:
CheckRSS("http://www.rubyxml.com/index.rb/rss")
private function CheckRSS(byval strRSS as string)
Dim reader as new XmlTextReader(strRSS)
Dim xmlDoc as new XmlDocument
Try
xmlDoc.Load(strRSS)
Catch ex As Exception
Response.Write("ERR in Rss File:" & strRSS
& "<br>")
Response.Write("Err: RSS File:" & ex.Message
& "<br>")
Exit Function
End Try
' load only the item nodes
Dim nodes As XmlNodeList = xmlDoc.SelectNodes
("/rss/channel/item")
For Each node As XmlNode In nodes
Try
Dim strPostTitle as string = node
("title").InnerXml
Dim strPost as string = node
("description").InnerXml
Dim strPostURL as string = node
("link").InnerXml
Dim strPostDate as string = node
("pubDate").InnerXml
response.write(strPostTitle & "<br>")
Catch ex As Exception
Response.Write("ERR in loading nodes: " &
ex.Message() & "<br>")
Exit Function
End Try
Next
end function
Can somebody tell me whats wrong with my code?
Thanks
I am loading a simple rss file via the XmlTextReader
and getting the following error:
Object reference not set to an instance of an object.
Here is the code which I use:
CheckRSS("http://www.rubyxml.com/index.rb/rss")
private function CheckRSS(byval strRSS as string)
Dim reader as new XmlTextReader(strRSS)
Dim xmlDoc as new XmlDocument
Try
xmlDoc.Load(strRSS)
Catch ex As Exception
Response.Write("ERR in Rss File:" & strRSS
& "<br>")
Response.Write("Err: RSS File:" & ex.Message
& "<br>")
Exit Function
End Try
' load only the item nodes
Dim nodes As XmlNodeList = xmlDoc.SelectNodes
("/rss/channel/item")
For Each node As XmlNode In nodes
Try
Dim strPostTitle as string = node
("title").InnerXml
Dim strPost as string = node
("description").InnerXml
Dim strPostURL as string = node
("link").InnerXml
Dim strPostDate as string = node
("pubDate").InnerXml
response.write(strPostTitle & "<br>")
Catch ex As Exception
Response.Write("ERR in loading nodes: " &
ex.Message() & "<br>")
Exit Function
End Try
Next
end function
Can somebody tell me whats wrong with my code?
Thanks