Jsoup select 或 - 如何 select <div> 元素内的所有 <p> 元素,除了最后一个 <p> 元素?

Jsoup selector - How to select all <p> elements inside <div> element, except for the last <p> element?

有一堆 html 个元素如下:

<div class="abc">
   <p>a</p>
   <p>b</p>
   <p>c</p>
   <p>x</p>
</div>

我想 select a, b, c 没有 x。我期待着得到您的支持。提前致谢。

使用css伪类notlast-child.

Elements e = doc.select(".abc p:not(:last-child)")