Xpath match current node or one of child nodes -
i'm having trouble creating xpath following html:
<html> <body> <table class="tablesorter"> <tbody> <tr class="tr_class"> <td>{some td info}</td> <td>{some td info}</td> <td> <span class="span1"> <span class="span2">out</span> <span class="span3">smth</span> <span class="span4">out</span> </span> </td> </tr> <tr class="tr_class"> <td>{some td info}</td> <td>{some td info}</td> <td>in</td> </tr> <tr class="tr_class"> <td>{some td info}</td> <td>{some td info}</td> <td>in</td> </tr> </tbody> </table> </body> </html>
what want create xpath return me content of each third td node (if doesn't have children) or content of it's span has class="span2". example, html should return
out,in,in
i have xpath return needed span node, looks like:
//table[@class = 'tablesorter']//td[3]/descendant::*[@class='span2']/text()
and have xpath return me simple content of each 3d td nodes:
//table[@class = 'tablesorter']//td[3][count(descendant::*)=0]/text()
but need 1 xpath, because me necessary have right ordering of 'in' or 'out' values (their ordering in table)
this it, no idea how robust "corpus":
//table[@class="tablesorter"]/tbody/tr/td[3]/descendant::text()[normalize-space(.)!=""]
['out', 'in', 'in']
update
//table[@class="tablesorter"]/tbody/tr/td[3]/descendant::text()[normalize-space(.)!=""][parent::td or parent::span[@class="span2"]]
Comments
Post a Comment