I asked the question in a codeplex discussion but I hope to get a quicker answer here at stackoverflow.
So, I use HTML Agility Pack for HTML parsing in C#.
I have the following html structure:
<body>
<p class="paragraph">text</p>
<p class="paragraph">text</p>
<p class="specific">text</p>
<p class="paragraph">text</p>
<p class="paragraph">text</p>
</body>
And I need to get all p elements with class “paragraph” that exist after the p element with class “specific”.
Is there a way to do that?
Thanks.
using .Class as in Mark’s example (if that doesnt exist, substitute whatever is appropriate)
Use SkipWhile
e.g. in LINQPad you get
5,6,7from:So depending on the type SelectNodes returns, either:
or
(or, ugly version)
(or in some cases – not if your expression is already filtering appropriately)
EDIT: I’d probably create an extension method:
Anyone care to search up prior art for this? Any good name suggestions?