Reputation: 87
I try to parse web page using the jsoup
, where I select element using the select
method of the jsoup
. I want to next element in the div
.
My page source is
<a class="class" href="href" title="title">
<img src="src" alt="alt"/>
</a>
I select the class element using the
Elements element = doc.select(".class");
I got result in the element
but I want to get image src also. How can I get it?
Upvotes: 0
Views: 1165
Reputation: 5538
You can get an attribute's value with the following method: attr(String key)
Example:
// Selects the first instance of img within .class
Element element = doc.select(".class img").first();
// Gets the value of the element's src
String src = element.attr("src");
Upvotes: 1