2017-08-16 13 views
0

要件:テキスト「ロスレス」を抽出します。HtmlAgilityを使用してスパン内のテキストを抽出する

<td nowrap="nowrap" align="center"> 
<span class="gen">4:59<br /><span style="color: red">Lossless</span></span> 
</td> 

私は全体のテキストを抽出できますことによってそれから "4 59Losslessを":

Dim divnodes As HtmlNode = doc.DocumentNode.SelectSingleNode("//td[@nowrap='nowrap']//span[@class='gen']") 

     If Not divnodes Is Nothing Then 
      MsgBox(div.InnerText) 
     End If 

私も

Msgbox(div.Attributes("style").Value) 

が、仕事なしを試してみました。

私にお答えできますか?

答えて

0

〜ありがとう、私はdivnodesではなく、何もThen`をISNOT場合は、Microsoftの[Visual Basicのコーディング規則]で推奨されているように、あなたは、 `使用することができますちなみに "/スパン"

  Dim divnodes As HtmlNodeCollection =doc.DocumentNode.SelectNodes("//td[@nowrap='nowrap']//span[@class='gen']/span") 

      If divnodes IsNot Nothing Then 
      For each div as HtmlNode in divnodes2 
       MsgBox(div.InnerText) 
      Next    
      End If 
+1

を追加することによって、それを解決した(HTTPS:/ /docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/program-structure/coding-conventions)を参照してください。 –

+0

@AndrewMortonさん、有益なリンクをありがとうございます。うん。彼らは "Not ... Is"の代わりに "IsNot"を使うことを提案しています。回答が更新されました! –

関連する問題