vb.net to catch HTML data Problem

Topics: Developer Forum, Project Management Forum, User Forum
Feb 13, 2011 at 9:12 AM

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??  

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("http://www.etnet.com.hk/www/tc/stocks/realtime/quote.php?code=3888"))
        Dim doc As New HtmlDocument()
        Dim docstockcontext As New HtmlDocument()

        Dim xnodes(1)
        doc.Load(ms, Encoding.UTF8)


        docstockcontext.LoadHtml(doc.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[3]/table[2]").InnerHtml)

        xnodes = docstockcontext.DocumentNode.SelectSingleNode("./span[1]").InnerText.Trim().Split("\n")

          Label1.Text = Mid(xnodes(0), 1)
                
       
    End Sub
End Class