Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

select table data using Xpath

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>
like image 329
Gayan Avatar asked May 13 '11 04:05

Gayan


1 Answers

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.

like image 117
Vaman Kulkarni Avatar answered Nov 20 '22 05:11

Vaman Kulkarni