Solved

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

Posted on 2014-02-10
5
963 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 39846747
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
ID: 39846757
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
ID: 39846764
Howabout IsNull (note I did say something like).
0
 

Author Comment

by:runnerjp2005
ID: 39846777
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
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
}
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 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