Jsoup select text after tag
java, jsoup
Solution
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**
Problem
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> ```