【发布时间】:2012-08-19 10:36:53
【问题描述】:
我已经下载了最新版本的 HtmlAgilityPack,在那里找到了几个文件夹,如 Net20、Net40 等。我创建了一个新项目并通过添加引用添加了 HtmlAgilityPack..(我从 Net20 文件夹中选择了 .dll),然后写道添加了using HtmlAgilityPack; 的简单代码。所以现在我有一个错误,即符号不能在 using-declaration 中使用。
怎么了?我想我在图书馆做错了什么。
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
}
}
}
}
【问题讨论】:
-
如果您要询问有错误的非工作代码,请发布 both code and 错误...不要让我们猜测。
-
不,我不是在问代码,我是在问如何正确添加.dll
-
How to use HTML Agility pack 的可能重复项
-
根据我的问题,只有“在您的应用程序中,在 HTMLAgilityPack\Debug(或 Realease)\bin 文件夹中添加对 HTMLAgilityPack.dll 的引用。”但我做到了。还是一样的错误。
-
有人知道该怎么做吗?您使用什么程序将 HTMLAgilityPack.dll 连接到项目?我也试过在我的mac上通过qt creator,但还是一样
标签: c# visual-studio-2010 html-agility-pack