Vojtěch Pešek
Vojtěch Pešek

Reputation: 1090

Parsing HTML with jsoup in android

I have problem with jsoup html parsing in android. I have this html:

<div class="bd-start-time">13:05<a name="channel-2-hour-12"></a></div>

I get all Elements with div class bd-start-time. I want to get only Elements with <a name="channel-2-hour-12"></a> and <div class="bd-start-time">. I´m sure, its an easy trick, but i cant find solution. Thanks for help.

EDIT:

Because my question wasnt clear enough, i try to explain it again. There are many <div class="bd-start-time">. I want to get only divs with this child <a name="channel-2-hour-12"></a>. And then from those divs, get the time 13:05. Thanks in advance

Upvotes: 0

Views: 224

Answers (1)

Peter Ambruzs
Peter Ambruzs

Reputation: 8213

This question is not entirely clear for me.

Maybe you want to use. Element child() method and ownText()

Element divElement = doc.select(".bd-start-time").first();
Element aElement = divElement.child(0);
String time = divElement.ownText();

Upvotes: 1

Related Questions