Find <ul> tags with HTML Agility Pack

fingaz1

New Member
I have the code:\[code\]var doc = new HtmlDocument();doc.LoadHtml(markup);var lists = doc.DocumentNode.SelectNodes("//ul");foreach (var list in lists){}\[/code\]But this throws the error:\[code\]Code >>> foreach (var list in lists)System.NullReferenceException: Object reference not set to an instance of an object.\[/code\]The value of \[code\]markup\[/code\] is:\[code\]<p>There are also lots of comments describing how it works.</p><p><ul><br> - Some list item<br> - Another one here<br> - Something else item<br> - Lol here<br></ul></p><h3>heading 2</h3>\[/code\]Can anyone tell me where I'm going wrong? I'm trying to find all instances of \[code\]<ul>....</ul>\[/code\] within the body. I know that I can check if \[code\]lists\[/code\] is null first, but it's still not finding any instances of \[code\]<ul>\[/code\] even though they exist in the body.
 
Back
Top