Error CS0246: The type or namespace name `HtmlAgilityPack' could not be found

c# html-agility-pack namespaces

Question

In order to translate the user input for my Natural Language Processing software, I presently utilize Google Translate as my dictionary.

using UnityEngine;
using System.Collections;
using System.Text;
using System.Net;
public class GoogleTranslate : MonoBehaviour {
    public static string Translate(string input, string languagePair, Encoding encoding)
    {
        string url = String.Format("http://www.google.com/translate_t?hl=en&ie=UTF8&text=       {0}&langpair={1}", input, languagePair);
        string result = String.Empty;

        using (WebClient webClient = new WebClient())
        {
            webClient.E ncoding = encoding;
            result = webClient.DownloadString(url);
        }

        HtmlDocument doc = new HtmlDocument();
        doc.LoadHtml(result);
        return doc.DocumentNode.SelectSingleNode("//textarea[@name='utrans']").InnerText;
    }
}

I'm really using Unity when I build this program in Assembly, however when I do, I get the following return error:

Assets/GoogleTranslate.cs(17,13): error CS0246: The type or namespace name `HtmlDocument' could not be found. Are you missing a using directive or an assembly reference?

I started searching online for the correct namespace for an HTML document and discovered that I needed to use:

using HtmlAgilityPack;

I entered this into my software and got the following error:

Assets/GoogleTranslate.cs(5,7): error CS0246: The type or namespace name `HtmlAgilityPack' could not be found. Are you missing a using directive or an assembly reference?

I discovered from web research that I needed to use:

using HtmlAgilityPack.HtmlDocument;

Even after adding that, I still keep getting the following error:

Assets/GoogleTranslate.cs(5,7): error CS0246: The type or namespace name `HtmlAgilityPack' could not be found. Are you missing a using directive or an assembly reference?

Which namespace should I use for HtmlDocument? Any assistance in this regard would be much appreciated.

1
4
9/25/2012 5:12:43 PM

Accepted Answer

Have you downloaded the HtmlAgilityPack dll and used it as a reference? Without mentioning it anywhere in your project or solution, it seems that you are attempting to utilize the (third-party) library.

Nu-Get may be used to install the library.

Install-Package HtmlAgilityPack
2
9/25/2012 5:15:36 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow