我已经下载了最新版本的 HtmlAgilityPack,在其中找到了几个文件夹,如 Net20、Net40 等。我创建了一个新项目并通过添加参考添加了 HtmlAgilityPack。(我从 Net20 文件夹中选择了 .dll),然后编写了一个简单的代码在哪里添加using HtmlAgilityPack;。所以现在我有一个错误,即符号不能在使用声明中使用。
怎么了?我想我在图书馆做错了什么。
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
int main()
{
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
    // There are various options, set as needed
    htmlDoc.OptionFixNestedTags=true;
    // filePath is a path to a file containing the html
    htmlDoc.Load(filePath);
    // Use:  htmlDoc.LoadXML(xmlString);  to load from a string
   // ParseErrors is an ArrayList containing any errors from the Load statement
   if (htmlDoc.ParseErrors!=null && htmlDoc.ParseErrors.Count>0)
   {
       // Handle any parse errors as required
   }
   else
   {
        if (htmlDoc.DocumentNode != null)
        {
            HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body");
            if (bodyNode != null)
            {
                // Do something with bodyNode
            }
        }
    }
}