nikhil udgirkar nikhil udgirkar - 1 year ago 51
HTML Question

I want to find the xpath for day separated by <br>

I have an HTML like this

<td class="FormLabel" valign="top">
<span class="DataLabel">Consists of:</span>
</td>
<td class="FormData">
<span class="BodyText">
Sunday<br>
Monday<br>
</span>
</td>


Here I want Xpath to just check for Sunday.

I had written Xpath like this

//span[contains(.,'Consis')]/parent::td/following-sibling::td/span[contains(.,'Sun')]


But this is not working as it is showing both days sunday and monday.
Help me with finding sunday or any particular day for that matter.

Answer Source

This is sunday

//span[contains(.,'Consis')]/parent::td/following-sibling::td/span[contains(.,'Sun')]/text()[1]

respectively, [2] is monday

Below part, containing sunday

//span[contains(.,'Consis')]/parent::td/following-sibling::td/span/text()[contains(.,'Sun')]