Solved

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

Posted on 2014-02-10
5
955 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

756 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