user1330645
user1330645

Reputation:

HTML.fromHTML - TagHandler in Android

I have a TextView and I want to set HTML to it with:

  HTML.fromHTML();

But I want to filter out all the <Img> tags with a taghandler and I want to save all links (src) in a List Array. Is that possible?

Thanks

Upvotes: 2

Views: 748

Answers (1)

Artyom Kiriliyk
Artyom Kiriliyk

Reputation: 2513

Yes this is possible. Yoo can use jsoup (Java HTML Parser) for easy HTML parsing i.e.

String url = "http://www.google.com";
List<String> images = new ArrayList<String>();
Document doc = Jsoup.connect(url).get();
Elements img = doc.select("img");
for (Element el : img)
{
    String imageUrl = el.attr("src");
    images.add(imageUrl);
}

Upvotes: 1

Related Questions