我是 C# XAML 和 Linq 初学者,我需要使用 linq 解析此 html 代码的帮助。我知道如何使用 linq 获取 strong> 标签之间的值,但我需要提取 td class= 'sivo' 之间的值并获取电影的英文名称,并获取其链接和在 https 链接之后显示的相应播放时间。
<div class='movieItemWrapper'>
<table cellspacing='2' cellpadding='0'>
<tr>
<td>
<strong>Riddick</strong>
</td>
</tr>
<tr>
<td class='sivo'>Riddick</td>
</tr>
<tr>
<td class='sivo'>DV. 11 -
<a href='https://some.text.here/performance.aspx?oid=C9A53000023KBHTNGF&coid=10000000014OCPXCOG' target='_blank'>16.50</a>, DV. 11 - <a href='https://some.text.here/performance.aspx?oid=20B53000023KBHTNGF&coid=10000000014OCPXCOG' target='_blank'>19.15</a>, DV. 7 - <a href='https://some.text.here/performance.aspx?oid=41B53000023KBHTNGF&coid=10000000014OCPXCOG' target='_blank'>20.00</a>, DV. 11 - <a href='https://some.text.here/performance.aspx?oid=05B53000023KBHTNGF&coid=10000000014OCPXCOG' target='_blank'>21.40</a>, DV. 7 - <a href='https://some.text.here/performance.aspx?oid=86B53000023KBHTNGF&coid=10000000014OCPXCOG' target='_blank'>22.30</a>,
</td>
</tr>
</table>
</div>
<div class='movieItemWrapper'>
<table cellspacing='2' cellpadding='0'>
<tr>
<td>
<strong>Domestic name</strong>
</td>
</tr>
<tr>
<td class='sivo'>The Conjuring</td>
</tr>
<tr>
<td class='sivo'>DV. 3 - <a href='https://some.text.here/performance.aspx?oid=2AA53000023KBHTNGF&coid=10000000014OCPXCOG' target='_blank'>17.00</a>, DV. 2 - <a href='some.text.here/performance.aspx?oid=4EA53000023KBHTNGF&coid=10000000014OCPXCOG' target='_blank'>19.00</a>, DV. 2 - <a href='https://some.text.here.hr/performance.aspx?oid=E3B53000023KBHTNGF&coid=10000000014OCPXCOG' target='_blank'>21.20</a>,
</td>
</tr>
</table>
</div>
我试过这段代码
var times = from tr in doc.DocumentNode.Descendants("tr")
from td in tr.Descendants("td").Where(x => x.Attributes["class"].Value == "sivo")
select td;