Checking null for htmlnode collection using c#

c# html-agility-pack html-parsing

Question

To parse the HTML using C#, I'm using the HTML Agility Pack.

 HtmlNodeCollection hNodes = myHtmDoc.DocumentNode.SelectNodes("//h1");

I am iterating over these hNodes. And sometimes it could be null. How to determine whether or not hNodes is null. IsNullOrEmpty can be used for strings. Like that, is there anything here that can be checked for null? I want the outcome to

If (hNodes != null)
 DoSomething
1
1
10/15/2012 7:30:32 AM

Accepted Answer

Your code is flawless since you checked the member's nullability in that phrase.

1
10/15/2012 7:32:45 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow