This project has moved and is read-only. For the latest updates, please go here. 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 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(""))
        Dim doc As New HtmlDocument()
        Dim docstockcontext As New HtmlDocument()

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


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

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