xml - Xpath OR over text node -
i catch text inside td tag want text not inside tag <strong>
or <b>
.
for instance case using b tag
<td class=""> <b>in care of name</b> text want catch </td>
for case can retrieve text using xpath expression
//td[starts-with(., "in care of name")]//text()[not(ancestor::b)]
and got expected result:
text want catch
or case using strong
<td class=""> <strong>in care of name</strong> text want catch </td>
for case can retrieve text using xpath expression
//td[starts-with(., "in care of name")]//text()[not(parent::strong)]
i try join 2 xpath on 1 using following expression :
//td[starts-with(., "in care of name")]//text()[not(parent::strong) or not(ancestor::b)]
and got
in care of name
text want catch
in fact got 2 elements of text , not expected.
any idea wrong. need change way solve this?
thanks in advance.
this xpath,
//td[starts-with(., "in care of name")]/text()
will return immediate text node children of td
string value starts in care of name
:
text want catch
for both of xml variations involving b
, strong
children of td
.
see testing text() nodes vs string values in xpath further details on differences between text nodes , string values in xpath.
Comments
Post a Comment