how can i fetch the tr which mention in code of this structure in nokogiri of in html response
<html>
<body>
<table>
</table>
<table>
<tbody>
<tr>
<td>
<table>
<tr></tr>
<tr><td> wanna this text as output.</td></tr>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>
I prefer using the CSS accessors as they’re more forgiving. Using your HTML sample, I’d use:
Alternately, the XPATH accessor is:
You’re looking for the nested table containing multiple rows. You want the last row.
Be wary whenever you look at the HTML inside a browser and see a
<table><tbody>combination. Browsers do a lot of code fix-up, which can result in tags that are not there when you retrieve the HTML directly and pass it into a parser. And, those non-existing tags you see in the browser’s output will throw off your CSS or XPath access when you add them in. In particular,<tbody>is a real common problem.