Skip to content
Discussion options

You must be logged in to vote

Hi,

There are a few ways to do this. The cleanest syntax might be to select on the element's children():

String html = "<div id=1>Outer <div id=2>One</div><div id=3>Two</div></div>";
Document doc = Jsoup.parse(html);
Element el = doc.expectFirst("div");
Elements inner = el.children().select("div");

Or, modify the selector to only match the children directly:

Elements inner = doc.select("div div");

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@midgleyc
Comment options

@jhy
Comment options

jhy May 2, 2025
Maintainer

Answer selected by midgleyc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants