我认为您需要使用正则表达式。在这里我发布一些代码。请检查一下。
String subjectString = "<a href=\"http://www.youtube.com\"><img alt=\"\" src=\"http://someImage.jpg\"></a>";
从图像标签获取 Href 链接的代码
Pattern titleFinder = Pattern.compile("<a[^>]*?href\\s*=\\s*((\'|\")(.*?)(\'|\"))[^>]*?(?!/)>", Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
Matcher regexMatcher = titleFinder.matcher(subjectString);
while (regexMatcher.find()) {
Log.i("==== Link0",regexMatcher.group(1));
}
从图像标签获取图像路径的代码
Pattern titleFinder = Pattern.compile("<img[^>]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>" , Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
Matcher regexMatcher = titleFinder.matcher(subjectString);
while (regexMatcher.find())
{
Log.i("==== Image Src",regexMatcher.group(1));
}