select table data using Xpath
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.
Gayan
I'm loud. I think I'm hungry for attention. I always kid people around. I think sometimes, I hurt their feelings. I always laugh really loud. I like to communicate with everybody but sometimes I just become very noisy. I like to change my attitude. I know God knitted me this way but I still want to change because I need it
Updated on March 24, 2020Comments
-
Gayan about 4 years
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>