I want to extract a text after each tag using jsoup. Is there any way to select it directly or do I have to perform .substring on the whole thing?
<div>
<a href="#"> I don't want this text </a>
**I want to retrieve this text**
</div>
public static void main(String... args) throws IOException {
Document document = Jsoup.parse("<div>"
+ "<a href=\"#\"> I don't want this text </a>"
+ "**I want to retrieve this text**" + "</div>");
Element a = document.select("a").first();
Node node = a.nextSibling();
System.out.println(node.toString());
}
Output
**I want to retrieve this text**
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