HTML敏捷性包 - 解析<李> [英] Html Agility Pack - Parsing <li>

查看:183
本文介绍了HTML敏捷性包 - 解析<李>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

欲刮除从简单的网站事实的列表。事实中的每一个被封闭在<李> 标记。使用HTML敏捷性包我将如何做到这一点?有没有更好的方法?

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?

括在唯一的东西&LT;李&GT; 标签都是事实,没有别的

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

推荐答案

是这样的:

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

这篇关于HTML敏捷性包 - 解析&LT;李&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆