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.