C# 从字符串而不是文档/url加载

C# 从字符串而不是文档/url加载,c#,html-agility-pack,C#,Html Agility Pack,我刚刚发现了html敏捷包,并尝试了它,但偶然发现了一个问题。我在网上找不到任何东西,所以我在这里尝试 您知道如何从字符串而不是文档/URL加载HTML吗 谢谢。您是否尝试过使用加载HTML string htmlString = 'Your html string here...'; HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument(); htmlDocument.LoadHtml(htm

我刚刚发现了html敏捷包,并尝试了它,但偶然发现了一个问题。我在网上找不到任何东西,所以我在这里尝试

您知道如何从字符串而不是文档/URL加载HTML吗


谢谢。

您是否尝试过使用加载HTML

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

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

// Do whatever with htmlDocument here

我认为有一个功能可以做到这一点,对吗

HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml("<test>");
HtmlDocument doc=新的HtmlDocument();
doc.LoadHtml(“”);

这篇文章可能有点旧了。我认为这会帮助别人

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

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