Solved

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

Posted on 2014-02-10
5
905 Views
Last Modified: 2014-02-10
Hi,

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
0
Comment
Question by:runnerjp2005
  • 3
  • 2
5 Comments
 
LVL 44

Expert Comment

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

Author Comment

by:runnerjp2005
Comment Utility
BC30451: 'isnull' is not declared. It may be inaccessible due to its protection level.

^ thats the error i get wiht the above
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
Howabout IsNull (note I did say something like).
0
 

Author Comment

by:runnerjp2005
Comment Utility
I get the same :S although isnull is something you can use surly lol
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
Comment Utility
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
}
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now