Patrick Burns
Patrick Burns

Reputation: 1833

xpath get all elements after element

I have this html

<td>
    <p> text <p>
    <p align="left"> some text <a href="">link</a> text and other staff </p>
    <p> text <p>
    <p> text <p>
    <p> text <p>
    <p> text <p>
</td>

How i can get all <p> after <p align="left"> ?

I write this xpath for getting <p align="left">, but how i can select all p elements after it?

//td/p[@align="left"][last()]

Upvotes: 5

Views: 4296

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167401

Use //td/p[@align="left"][last()]/following-sibling::p.

Upvotes: 9

Related Questions