25

I just found out about html agility pack and I tried it, but stumbled upon a problem. I couldn't find anything on the web so I am trying here.

Do you know how I can load the HTML from a string instead of document/URL?

Thanks.

KaraKaplanKhan
  • 734
  • 1
  • 14
  • 31
Darko
  • 535
  • 1
  • 6
  • 15

3 Answers3

59

Have you tried using LoadHtml?

string htmlString = 'Your html string here...';

HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
htmlDocument.LoadHtml(htmlString);

// Do whatever with htmlDocument here
ohaal
  • 5,208
  • 2
  • 34
  • 53
3

i think there's a function to do that right?

HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml("<test>");
melaos
  • 8,386
  • 4
  • 56
  • 93
-1

This post might be bit old. I think it will help others.

        WebBrowser web_browser = new WebBrowser();
        web_browser.DocumentText = html_contents_as_string;

        do
        {
            Application.DoEvents();
        } while (web_browser.ReadyState != WebBrowserReadyState.Complete);