【发布时间】:2010-09-13 00:39:38
【问题描述】:
这是我的代码片段:
Dim content As String = ""
Dim web As New HtmlAgilityPack.HtmlWeb
Dim doc As New HtmlAgilityPack.HtmlDocument()
doc.Load(WebBrowser1.DocumentStream)
Dim hnc As HtmlAgilityPack.HtmlNodeCollection = doc.DocumentNode.SelectNodes("//div[@class='address']/preceding-sibling::h3[@class='listingTitleLine']")
For Each link As HtmlAgilityPack.HtmlNode In hnc
Dim replaceUnwanted As String = ""
replaceUnwanted = link.InnerText.Replace("&", "&") '
<span style="white-space:pre"> </span> content &= replaceUnwanted & vbNewLine
Next
'I have a bunch of code here I removed ------------------------------
Dim htmlDoc As HtmlDocument = Me.WebBrowser2.Document
Dim visibleHtmlElements As HtmlElementCollection = htmlDoc.GetElementsByTagName("TD")
Dim found As Boolean = False
For Each str As HtmlElement In visibleHtmlElements
If Not String.IsNullOrEmpty(str.InnerText) Then
Dim text As String = str.InnerText
If str.InnerText.Contains(parts(2)) Then
found = True
End If
End If
Next
Me.WebBrowser2.Document 出现错误:
“'System.Windows.Forms.HtmlDocument' 类型的值无法转换为 'HtmlAgilityPack.HtmlDocument'。
另外一个是 htmlDoc.GetElementsByTagName:
“GetElementsByTagName”不是“HtmlAgilityPack.HtmlDocument”的成员。
当我不使用 HAP 时,代码可以工作,但我需要导入它来做某事,现在它干扰了这个。请帮忙。
【问题讨论】: