我刚刚发现了Html Agility Pack并尝试使用它,但遇到了一个问题。我在网上找不到任何相关的信息,所以来这里请教。
您知道如何从字符串中加载HTML而不是从文档/URL中加载吗?
谢谢。
您知道如何从字符串中加载HTML而不是从文档/URL中加载吗?
谢谢。
你尝试使用过 LoadHtml 吗?
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>");
这篇文章可能有点旧了,但我认为它会对其他人有所帮助。
WebBrowser web_browser = new WebBrowser();
web_browser.DocumentText = html_contents_as_string;
do
{
Application.DoEvents();
} while (web_browser.ReadyState != WebBrowserReadyState.Complete);