i used to select table with class name "list". I use this xpath query to select node in Htmlagilitypack
//table[@class="list"]/td/a[@href]
but couldn't get correct output. What's wrong with my xpath code block?
This is the table that i want to grab the data from:
<table class="list">
<tbody>
<tr>
<td width="315">
<b>1</b> <a href="http://www.url.html">data</a><br>
<b>2</b> <a href="http://www.url.html">data</a><br>
<b>3</b> <a href="http://www.url.html">data</a><br>
</td>
</tr>
</tbody>
</table>
I consider that you need to get href
values of all the anchors. For that you could use
//table[@class='list']//td/a/@href
Your XPath did not work because you are trying to find such a <TD>
which is immediate child of <TABLE>
which is not the case in the code snippet you've shown. Hence use //TD in your XPath.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With