如何使用Html Agility Pack选择特定节点?

时间:2013-04-18 17:02:38

标签: c# html-agility-pack

<div class="form-field wide-80 normal">1997-09-15</div>

我正在尝试选择1997-09-15内的日期。我尝试了这段代码,但它给出了“Xpath异常未处理”的错误代码中有什么问题请帮忙

 string Url = "http://whois.domaintools.com/google.com";

 HtmlWeb web = new HtmlWeb();
 HtmlAgilityPack.HtmlDocument doc = web.Load(Url);

 var SpanNodes = doc.DocumentNode.SelectNodes("//div[@class=form-field wide-80 normal]");
 if (SpanNodes != null)
 {
      foreach (HtmlNode SN in SpanNodes)
      {
          string text = SN.FirstChild.InnerText.Trim();
          MessageBox.Show(text);
      }
 }

1 个答案:

答案 0 :(得分:1)

你忘了' s

var SpanNodes = 
       doc.DocumentNode.SelectNodes("//div[@class='form-field wide-80 normal']");