Search adjacent node in xml via xpath

I have a deeply nested structure (actually parsing xhtml, so many unpleasant ones), for example:

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

and this is repeated in a long table. I need an xpath expression that selects the second font tag (or rather - text()). I looked at the axis preceding-sibling, but something is not working so well.

something along the lines (and forgive me if it's funny, my xpath is rusty)

//tr[preceding-sibling::tr/td/font]/td/text()
+3
source share
2 answers

Using

(//tr/td[font])[2]/font/text()

This means :

< node font, td , font - tr.

, preceeding .

+5

. , /b .

0

Source: https://habr.com/ru/post/1782224/


All Articles