Link to home
Start Free TrialLog in
Avatar of Member_2_5230414
Member_2_5230414

asked on

BC30203: Identifier expected in a n if statement

I am getting the error "BC30203: Identifier expected." on this line if Div.selectSingleNode("./td[@class='score']").InnerText != null then and i can't figure out why...


		For Each div As Object In htmlDoc.DocumentNode.SelectNodes("//div[@class='matches']")' select all the divs within the code that contain *
 
    if Div.selectSingleNode("./td[@class='score']").InnerText != null then
		  lblHTMLOutput.Text += Div.selectSingleNode("./td[@class='score']").InnerText
    end if
        Next

Open in new window

Avatar of Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

Hi,

Use the following instead:

if Div.selectSingleNode("./td[@class='score']").InnerText <> nothing then

Open in new window


Giannis
Avatar of Member_2_5230414
Member_2_5230414

ASKER

Hi Giannis,


I now get the error

System.NullReferenceException: Object variable or With block variable not set.
Hmmm... Try the following:

if not Div.selectSingleNode("./td[@class='score']") is nothing then

Open in new window


if that doesn't work, plz provide a sample html where you get the error(if it is different than your other question), and possibly provide more of your code.

Giannis
I have updated my previous post.
Operator '<>' is not defined for type 'HtmlNode' and 'Nothing'. is the error i get now....

full code is

Imports System.Net 
Imports System.IO 
Imports HtmlAgilityPack

Partial Class football_home
    Inherits System.Web.UI.Page

		Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
			
Dim webGet As New HtmlWeb() 'open the system
        Dim htmlDoc As HtmlDocument = webGet.Load("http://www.livefutbol24.com/Football/Live")'' get the html from the webpage

      

		For Each div As Object In htmlDoc.DocumentNode.SelectNodes(".//div[@class='matches']")' select all the divs within the code that contain *
 
   if Div.selectSingleNode(".//td[@class='score']") <> nothing then
		  lblHTMLOutput.Text += Div.selectSingleNode(".//td[@class='score']").InnerText
		  end if
 
        Next  End Sub
	
End Class

Open in new window


its different from other question as im looking to deal with null values
ASKER CERTIFIED SOLUTION
Avatar of Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial