このコードがジェネリック リストの ID を返さないのはなぜですか。Web ページの div 要素には必ず id があります。ポイントを壊すと、プロパティId
にIDがなく、機能DocumentNode.SelectNodes
しhtmlDoc.DocumentNode.SelectNodes("//div[@id]")
ません。.NET 2.0 と HtmlAgilityPack.dll 1.4.0.0 を使用しています。
Imports HtmlAgilityPack
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim listHtmlFound As List(Of String) = New List(Of String)
Dim webGet As HtmlWeb = New HtmlWeb
Dim htmlDoc As HtmlDocument = webGet.Load("http://stackoverflow.com/q/11528387/1350308")
htmlDoc.OptionUseIdAttribute = True
'Dim s As Object = htmlDoc.DocumentNode.SelectNodes("//div/@id").Count
For Each div As HtmlNode In htmlDoc.DocumentNode.SelectNodes("//div")
listHtmlFound.Add(div.Id)
Next
End Sub
End Class