HTMLAgilitypack -> Check to see if htmlDoc.DocumentNode.SelectNodes is null

Posted on 2014-02-10
Medium Priority
Last Modified: 2014-02-10

I am using the following line to loop through some html

For Each div As Object In htmlDoc.DocumentNode.SelectNodes(".//li[@class='avb-row IN_PLAY']")

Open in new window

The problem is at the moment there are no values with li[@class='avb-row IN_PLAY']")

how can i check that if li[@class='avb-row IN_PLAY']") <> Null before I do the
Question by:runnerjp2005
  • 3
  • 2
LVL 45

Expert Comment

ID: 39846747
something like:
if not isnull(htmlDoc.DocumentNode.SelectNodes(".//li[@class='avb-row IN_PLAY']")) then
  your for loop goes here
end if

Author Comment

ID: 39846757
BC30451: 'isnull' is not declared. It may be inaccessible due to its protection level.

^ thats the error i get wiht the above
LVL 45

Expert Comment

ID: 39846764
Howabout IsNull (note I did say something like).

Author Comment

ID: 39846777
I get the same :S although isnull is something you can use surly lol
LVL 45

Accepted Solution

AndyAinscow earned 2000 total points
ID: 39846787
I've found this with a quick search, you could try the VB equivalent:
HtmlNodeCollection coll = htmlDoc.DocumentNode.SelectNodes(your path goes here);
if (coll != null)
    // do stuff

Featured Post

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question