JSoup - Parsing this nested HTML unordered list

DIRTY DAVE :

I'm trying to parse this nested HTML from a website but I just can't seen to figure out how to get the data out of the unordered list.

<ul class="no-bullet participants-list" data-registrations="registrants">
     <li class="participant" data-participant-id="512028" data-registrations="registrant">
         <div class="row collapse participant-info">
             <div class="large-1 small-2 columns"> 
                 <figure class="participant-avatar">
                    <a class="user-profile-link" href="THE LINK I WANT">

What I've tried

for(Element row : doc.select("ul.no-bullet participants-list")) {
         row.select("li.participant")
             .select("div.row collapse participant-info")
             .select("div.large-1 small-2 columns")
             .select("figure.participant-avatar")
             .select("a.href").text());
}

Not sure what I'm doing wrong

Almas Abdrazak :

As I understand you are looking for href attribute inside a tag Your's select statement is not correct because you use space instead of dot in order to choose class

Instead of this

doc.select("ul.no-bullet participants-list")

Use this

doc.select("ul.no-bullet.participants-list a").first().attr("href")

As you see I chose first a tag and fetched href from this tag

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=422626&siteId=1