[英]How to add HtmlAgilityPack to the Visual Studio 2010 project
I've downloaded the latest version of HtmlAgilityPack, where have found several folders like Net20, Net40 and etc. I created a new project and added HtmlAgilityPack via add Reference.. (I chose .dll from Net20 folder), then wrote a simple code where added using HtmlAgilityPack;
我下载了最新版本的HtmlAgilityPack,在其中找到了几个文件夹,例如Net20,Net40等。我创建了一个新项目,并通过添加引用添加了HtmlAgilityPack。.(我从Net20文件夹中选择了.dll),然后编写了一个简单的代码using HtmlAgilityPack;
添加的位置using HtmlAgilityPack;
. 。 So now i have an error that symbol cannot be used in a using-declaration. 所以现在我有一个错误,该符号不能在使用声明中使用。
What's wrong? 怎么了? i guess that i did something wrong with the library. 我想我在图书馆做错了事。
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
}
}
}
}
通过右键单击项目解决方案中的参考文件夹/ bin添加参考
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.