Reputation: 29519
Simplified example
<td>caption</a>
<a id="tt-1">text1</a>
<a id="tt-2">text2</a>
<td>topics</td>
<a id="tt-3">text3</a>
<a id="tt-4">text4</a>
<a id="tt-5">text5</a>
What I need is to match all a
elements below <td>topics</td>
.
Note that there are plenty of elements between those elements in example. Also <td>
may be enclosed into other elements.
My current real-world XPath expression looks like this
//a[contains(@id,'tt-')]
Updated to be closer to real-world
Another update to clarify.
Upvotes: 0
Views: 107
Reputation: 338108
Based on your statement "What I need is to match all a elements below <td>topics</td>
"
//td[.='topics']/a
I'm sure that's not the whole story, though.
Based on your updated example:
//a[starts-with(@id, 'tt-') and preceding-sibling::td[1] = 'topics']
Upvotes: 2