Fatal510
Fatal510

Reputation: 1723

Html Agility Pack - Parsing <li>

I want to scrape a list of facts from simple website. Each one of the facts is enclosed in a <li> tag. How would I do this using Html Agility Pack? Is there a better approach?

The only things enclosed in <li> tags are the facts and nothing else.

Upvotes: 4

Views: 7592

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1062512

Something like:

List<string> facts = new List<string>();
foreach (HtmlNode li in doc.DocumentNode.SelectNodes("//li")) {
    facts.Add(li.InnerText);
}

Upvotes: 5

Related Questions