2012-02-27 67 views
15

我剛剛發現了關於html敏捷包的問題,​​我試了一下,但偶然發現了一個問題。無法在網上找到任何東西,所以在這裏嘗試。從字符串加載而不是文檔/網址

你知道我如何從一個字符串而不是文檔/ URL加載html嗎?

感謝

回答

42

您是否嘗試過使用LoadHtml

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

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

// Do whatever with htmlDocument here 
1

我認爲有一個功能可以做到這一點嗎?

HtmlDocument doc = new HtmlDocument(); 
      doc.LoadHtml("<test>"); 
-1

此帖可能有點舊。我認爲這會幫助他人。

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

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