Sujit Soni Sujit Soni - 7 months ago 36
HTML Question

How to get text outside tag

Want to get text which is outside a tag. Here is the HTML:

<table border="0" cellpadding="0" cellspacing="0" width="100%"
class="viewingsCommentsTbl">
<tbody>
<tr>
<td>
<b style="border: 2px solid red;
background: rgb(204, 136, 136);">Viewing Conducted: </b>
18-May-2016
</td>
</tr>
<tr>
<td style=""><b style="">Duration: </b> 1 hr</td>
</tr>
<tr>
<td style=""><b style="">Comments: </b>66yy</td>
</tr>
</tbody>
</table>


I wanted to get date i.e
"18-May-2016"


I tried following XPath, but it does not work:

//*[@class="viewingsCommentsTbl"]/tbody/tr[1]/td/b

Guy Guy
Answer

The text is in the <td> tag, not the <b>. Try

//*[@class="viewingsCommentsTbl"]/tbody/tr[1]/td