Xpath extract equipment

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,717
Location
Sydney, Australia
Programming Experience
10+
it gives me an error "Object reference not set as an instance of an object"
What is "it"? Don't expect us to tell you what's wrong with your code if you refuse to show us your code. Also, don't just send us off to a web site and expect us to work out what you actually want from it. Show us the specific data you're working with and explain exactly what you want out of it. You need to provide a FULL and CLEAR explanation of the problem. Don't expect us to spend time working things out that you already know. Do all you can to help us help you and then we'll be more likely to help you.
 

avrx

New member
Joined
Jan 28, 2022
Messages
4
Programming Experience
10+
I'm sorry or I remembered to put the code here my problem

Try

Dim url As WebRequest = WebRequest.Create("Jornada 19 de Primera División - laliga,la liga santander,liga española,primera division españa,primera división española,liga españa,primera,primera division,liga,la liga - Resultados de Fútbol")
Dim respose As WebResponse = url.GetResponse
Dim PAGINA As New StreamReader(respose.GetResponseStream())
Dim MIHTML As String = PAGINA.ReadToEnd()

Dim html = New HtmlDocument()
html.LoadHtml(MIHTML) 'pasando tu string con el HTML

Equipos_Local = (html.DocumentNode.SelectSingleNode(".//html/body/div[6]/div[3]/div[10]/div/div[4]/div[1]/div[2]/table/tbody/tr[1]/td[3]/a[2]").InnerText)

TxtBoxEquipo.text = Equipos_Local

Catch ex As Exception

MsgBox(ex.Message)

End Try
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,603
Location
Norway
Programming Experience
10+
Use id attributes whenever you can to narrow the search path, for example "//table[@id=""tabla1""]"
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,603
Location
Norway
Programming Experience
10+
Maybe add the part after table? ...]/tbody....
 

avrx

New member
Joined
Jan 28, 2022
Messages
4
Programming Experience
10+
something like that?

(html.DocumentNode.SelectSingleNode(".//html/body/div[6]/div[3]/div[10]/div/div[4]/div[1]/div[2]/table/tbody/tr[1]/td[3]/a[2]").InnerText)

"//table[@id=""tabla1""]/tbody/tr[1]/td[3]/a[2]"
 

Latest posts

Top Bottom