Xpath simplification: extract text of self and child node -


having html-snippet

<td class="info">self-text <br> <b>child-text</b> </td> 

i extract self-text , child-text. far using regex:

.//td[contains(@class, 'info')]/text() | .//td[contains(@class, 'info')]/b/text() 

is there simpler way this?

you can use following xpath expression return all non-empty text nodes anywhere within outer td element :

.//td[contains(@class, 'info')]//text()[normalize-space()] 

Comments