2016-10-10 10 views
0

これは本当に基本的なものですが、動作させることができないと思っています。私が試したすべての例は私にとってはうまくいきません。すべてのスパンをクラス名で取得しますか?

<span class="st">text here</span> 

いくつかのコード:ここで

Dim doc As New HtmlAgilityPack.HtmlDocument() 
doc.LoadHtml(Content) 
'? 

は、私が試したし、それを取得何私は単純に、クラス名「聖」のページ上のすべてのスパンの内部テキストを取得するためにしようとしていますジャック:ここ

For Each node As HtmlNode In doc.DocumentNode.Descendants("//span[@class='st']") 
     Dim value As String = node.InnerText 
     MessageBox.Show(value) 
Next 

答えて

0

は最終的に働いていたものです:

Dim findclasses = doc.DocumentNode.Descendants("span").Where(Function(d) d.Attributes.Contains("class") AndAlso d.Attributes("class").Value.Contains("st")) 


     For Each f In findclasses 
      MessageBox.Show(f.InnerText) 
     Next 
関連する問題