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]/td/text()
Use:
(//tr/td[font])[2]/font/text()
This means:
Select all text-node children of all font elements that are children of the second td in the document that has a font child and is itself a child of some tr element.
As you can see, no preceeding axis is necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With