A
A
artshelom2018-05-09 15:26:48
Java
artshelom, 2018-05-09 15:26:48

How to use Jsoup to take only the first layer of divs??

How to take only the first layer, without child divs.
For example, there is this html code:

<div class="1">
        <div class="1">...</div>
        <div class="2">...</div>
</div>
<div class="2">
        <div class="1">...</div>
</div>

It is necessary to take only 1 layer from it, that is, divs with class 1 and 2 that hold child divs.
(I hope I expressed myself correctly)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2018-05-09
@artshelom

text = "..."
Jsoup.parse(text).select("body > div")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question