このようなhtmlページがあります
<li class="liclass">
some html
<a href="blabla" class="first aclass">
some other html
</li>
<li class="liclass">
some html
<a href="blabla" class="first aclass">
some other html
</li>
<li class="liclass">
some html
<a href="blabla" class="first aclass">
some other html
</li>
...
lis からすべての href を取得したいのですが、このように、li と a タグの間の関係を取得できます。したがって、最初の li は最初のタグに移動し、2 番目から 2 番目に移動します。
私はこのコードを持っていますが、常に同じ a href コンテキストを返します:
foreach (var node in docu.DocumentNode.SelectNodes("//li[@class='liclass']"))
{
String href = node.SelectNodes("//a[@class='first aclass']")[0].Attributes["href"].Value
}
そのコードを改善するにはどうすればよいですか?