简体   繁体   中英

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; . 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添加参考

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM