htmlagilitypack may be used to get p tags that come after a specified tag.

c# html-agility-pack web-crawler

Question

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))

1
0
11/1/2011 8:16:05 PM

Popular Answer

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);
1
3/16/2015 2:50:47 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