Skip to content Skip to sidebar Skip to footer

Get Specific Element Inside Other Element With HtmlAgilityPack In C#

I'm working on a project where I need to parse a lot of html files. I need to get every

from within one

So far I have this code and it does

Solution 1:

That's a rather simple thing to do, you just have to add a . to the string like .//p, that way you get only child nodes of the current node.

Another way would be to just call SelectNodes like this:

doc.DocumentNode.SelectNodes("//div[(@class='story-body')]/p");

Post a Comment for "Get Specific Element Inside Other Element With HtmlAgilityPack In C#"