gpt4 book ai didi

android - JSoup 解析 : get next element

转载 作者:太空狗 更新时间:2023-10-29 15:26:00 24 4
gpt4 key购买 nike

我找遍了,找不到办法。我有一组元素。我从这个组中选择一个元素。我怎样才能找到这个选定元素之后的下一个元素?

最佳答案

使用方法nextElementSibling()

例子:

<body>
<p>First in family!</p>
<p>Second in family!</p>
<p>Third in family!</p>
</body>

J汤:

Element firstParagraph = doc.select("p:eq(0)").first();
Element secondParagraph = firstParagraph.nextElementSibling();

System.out.println(firstParagraph.text() + " " + secondParagraph.text());

Output: First in family! Second in family!

关于android - JSoup 解析 : get next element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19393402/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com