使用 HtmlAgility 提取范围内的文本



要求:提取文本"无损"。

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

我只能通过以下方式从中提取全文"4:59无损":

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)

但没有工作。

你能对我说一声吗?谢谢~

我通过添加"/span"解决了它

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

最新更新