Use Load()
method if you have the URL, and use LoadHtml()
if you have the html page. It appears that you need the first method in this case :
htmlDoc.Load(htmlWeb)
As you asked as an example, to get body tag you can use this simple XPath //body
UPDATE :
I missed the fact that HAP's HtmlDocument
, unlike XDocument
, can't Load
directly from URL. The method only accept path to a file in local machine. To load HtmlDocument
from URL you need to use HtmlWeb
's Load()
method instead. Try this way :
Dim htmlWeb As New HtmlWeb
Dim htmlDoc As HtmlAgilityPack.HtmlDocument = htmlWeb.Load(URL)
Dim htmlText As String
htmlDoc.OptionFixNestedTags = True
Dim myBR As HtmlNode = htmlDoc.DocumentNode.SelectSingleNode("//body")
htmlText = myBR().InnerText