2

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

1 Answer 1

1

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);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.