How to add HtmlAgilityPack to the Visual Studio 2010 project

c# html-agility-pack visual-studio-2010

Question

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
            }
        }
    }
}

Popular Answer

add reference by right clicking reference folder/bin in project solution




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why