Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-02-10
5
Medium Priority
?
1,008 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 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
}
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

730 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