tags:

views:

57

answers:

1

Hello

Apologies if this has been answered before.

I've been trying to construct an XPath expression to retrieve only the text portion from an element such as this (containing text as well as other elements)

...
  <td id="test">
     The text I want.
     <table>
        Things I do not want
        .....
        .....
  </td>

I haven't been able to find any way to separate "the text I want" from the other content inside the element.

Your help is appreciated.

+3  A: 

//td/text() should retrieve the text node children under td, when the first node rule is in effect, this will be the one you want, otherwise, filter this with square brackets if you want a particular text child

Paul Butcher
Thank you, this worked.
Nick