I would like catch a text inside td tag but only want the text that is not inside the tag <strong>
or <b>
.
For instance the case using b tag
<td class="">
<b>In Care Of Name</b>
text that I want to catch
</td>
For this case I can retrieve the text using this xpath expression
//td[starts-with(., "In Care Of Name")]//text()[not(ancestor::b)]
and I got the expected result:
text that I want to catch
or the case using strong
<td class="">
<strong>In Care Of Name</strong>
text that I want to catch
</td>
For this case I can retrieve the text using this xpath expression
//td[starts-with(., "In Care Of Name")]//text()[not(parent::strong)]
I try to join this two xpath on one using the following expression :
//td[starts-with(., "In Care Of Name")]//text()[not(parent::strong) or not(ancestor::b)]
And I got
In Care Of Name
text that I want to catch
In fact I got two elements of text and that is not what I expected.
Any idea about what is wrong. Do I need change the way to solve this?
Thanks in advance.