我将如何只选择此 h3 中的周数而不选择其中的 span 标签?
仅选择包含 span 的 H3 会导致将一些 ascii 文本添加到生成的消息框中。
结果:
 Week 1
源文件:
<h3>
<span> </span>Week 1</h3>
代码:
private void getWeekNumber(string url)
{
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
htmlDoc.Load(new System.IO.StringReader(url));
foreach (HtmlAgilityPack.HtmlNode h3 in htmlDoc.DocumentNode.SelectNodes("//h3"))
{
MessageBox.Show(h3.InnerText);
}
}
最佳答案
关于c# - 使用 Html Agility Pack 抓取 H3 的 InnerText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11526636/