0
我看到很多類似的帖子,他們都談論SelectSingleNode返回null。我不太確定我的問題與此有關。也許我有一些我無法弄清楚的問題。在這裏我的代碼:SelectNode在Html敏捷包中返回Null
string url = "https://www.google.com/#q=nothing";
HtmlWeb web = new HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
web.Load(url);
var nodes = doc.DocumentNode.SelectNodes("//div[@class='content']");
if (nodes != null) {
foreach(HtmlNode item in nodes) {
if (item != null) {
string s = item.InnerText;
listView1.Items.Add(s);
}
}
} else {
MessageBox.Show("Nothing found here");
}