skykingdom
New member
- Joined
- Feb 13, 2011
- Messages
- 1
- Programming Experience
- 1-3
hi everyone,
I have the code using vb.net to catch HTML data say price,high,low and open etc. I dont know what happen why always get an error: System.NullReferenceException in below marking in red. Any expert can help to correct for me??
I have the code using vb.net to catch HTML data say price,high,low and open etc. I dont know what happen why always get an error: System.NullReferenceException in below marking in red. Any expert can help to correct for me??
VB.NET:
Imports HtmlAgilityPack
Imports System.Net
Imports System.IO
Imports System.Text
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim client As New WebClient
Dim ms = New MemoryStream(client.DownloadData("[URL="http://www.etnet.com.hk/www/tc/stocks/realtime/quote.php?code=3888"][COLOR=#3e62a6]http://www.etnet.com.hk/www/tc/stocks/realtime/quote.php?code=3888[/COLOR][/URL]"))
Dim doc As New HtmlDocument()
Dim docstockcontext As New HtmlDocument()
Dim xnodes(1)
doc.Load(ms, Encoding.UTF8)
[COLOR=#ff00ff]docstockcontext.LoadHtml(doc.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[3]/table[2]").InnerHtml)[/COLOR]
xnodes = docstockcontext.DocumentNode.SelectSingleNode("./span[1]").InnerText.Trim().Split("\n")
Label1.Text = Mid(xnodes(0), 1)
End Sub
End Class
Last edited by a moderator: