I'm trying to get some name form class
attribute within a website html
page by using Jsoup
Library, The problem is that i'm getting the elements by class using getElementsByClass("name")
and store it into a string variable and
the result coming like this "mike andro rob banks maria gerardo louis....etc".
but what i want is to separate the individual names and store them into array.
the following is the code snippet:
public String processText(String htmlPage) {
Document html = Jsoup.parse(htmlPage);
String names = html.body().getElementsByClass("name").text();
return names;
}
More information:
The source page is an html
page and i am saving the full html code in a string and then process the string to extract only the Elements under the class="name"
htmlPage
which i am passing to processText
method is similar to the following:
<div class="name">
Rob Kardashian
</div>
</div>
</a>
</div>
<div class="channelListEntry">
<a href="/zayn_malik">
<div class="image">
<img src="http://cdn.posh24.com/images/:profile/014cf47ca44daf8f44a3e0720929ee327" alt="Zayn Malik"/>
</div>
<div class="info">
<div class="status-container">
<div class="position">4</div>
<div class="img pos"></div>
<div class="value">+12</div>
</div>
<div class="name">
Zayn Malik
</div>
</div>
</a>
</div>
<div class="channelListEntry">
<a href="/kanye_west">
<div class="image">
<img src="http://cdn.posh24.com/images/:profile/03f352f71ffab135cd81821eb190d4832" alt="Kanye West"/>
</div>
<div class="info">
<div class="status-container">
<div class="position">5</div>
<div class="img pos"></div>
<div class="value">+16</div>
</div>
<div class="name">
Kanye West
</div>
</div>
</a>
</div>
<div class="channelListEntry">
<a href="/kendall_jenner">
<div class="image">
<img src="http://cdn.posh24.com/images/:profile/066d5c02547c4357f1bc5f633c68f4085" alt="Kendall Jenner"/>
</div>