I'm crawling a website using htmlagilitypack c#:
i have in the source code of an html page
....
<p>this a p that come before h3</p>
....
....
<h3>this h3 </h3>
<p>first p after h3</p>
....
<p>seconde p after h3</p>
i want to to all get all Ps that come after
is there a way to use a where to filter Ps using position.
where (position(p)>position(h3))
Try the following code:
var htmlText = "source code of your html page";
var htmlDoc.LoadHtml(htmlText);
var h3= htmlDoc.DocumentNode.SelectNodes("//h2");
var lineNum = h3[0].Line;
var p = htmlDoc.DocumentNode.SelectNodes("//p").Where(x => x.Line > lineNum);