简体   繁体   中英

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

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

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM