finding an adjacent node in xml through xpath

Posted by kolosy on Stack Overflow See other posts from Stack Overflow or by kolosy
Published on 2010-12-27T02:47:33Z Indexed on 2010/12/27 2:54 UTC
Read the original article Hit count: 255

Filed under:
|

i have a deeply nested structure (actually parsing out xhtml, so lots of nasty), like so:

<tr>
  <td>
    <font id="blah">
      stuff
    </font>
  </td>
</tr>
<tr>
  <td>
      more stuff
  </td>
</tr>

and this repeats in a long table. i need an xpath expression that will select the second font tag (or rather it's text()). i was looking at the preceding-sibling axis, but something isn't quite working right.

something along the lines of (and pardon me if this is ridiculous, my xpath is rusty)

//tr[preceding-sibling::tr/td/font/b]/td/text()

© Stack Overflow or respective owner

Related posts about Xml

Related posts about xpath