简体   繁体   中英

How to use XPath to select following-sibling?

<tr>
  <td width="120" align="right" class="tit">application date:</td>
  <td><span style="text-decoration: underline;color: #0066ff;cursor: pointer"  
       onclick="_search('ad','2016.01.18');">2016.01.18</span></td>
</tr>

How can I use XPath to get the date value "2016.01.18"? The dates after "ad" are different.

You can use the following XPath-1.0 expression to select the following <span> of the <td> which contains application date :

//td[contains(text(),'application date')]/following-sibling::td[1]/span

Output is:

2016.01.18

This XPath,

//td[normalize-space()='application date:']/following-sibling::td[1]/span/text()

will return

2016.01.18

as requested.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM