0
這裏是我的代碼剪斷干擾:HtmlAgilityPack我的代碼(不是HtmlAgilityPack問題)
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時,代碼正常工作,但我需要導入它來執行某些操作,現在它干擾了此操作。請幫助。
謝謝Dan幫助了很多,非常感謝。 – Datadayne 2010-09-13 01:13:45