扩展这个问题
How to extract an image src from RSS feed
对于JAVA,ios已经有了答案,但是要让它在JAVA中工作,还没有足够的解决方案。
RSS Feeds 解析直接标签对我来说是众所周知的,但是解析另一个标签内的标签非常复杂,如下所示
<description>
<![CDATA[
<img width="745" height="410" src="http://example.com/image.png" class="attachment-large wp-post-image" alt="alt tag" style="margin-bottom: 15px;" />description text
]]>
</description>
如何单独拆分src标签?
最佳答案
看看jsoup .我认为这就是您所需要的。
编辑:
private String extractImageUrl(String description) {
Document document = Jsoup.parse(description);
Elements imgs = document.select("img");
for (Element img : imgs) {
if (img.hasAttr("src")) {
return img.attr("src");
}
}
// no image URL
return "";
}
关于java - RSS Feed - 在 JAVA 中的描述标签内解析/提取 src 图像标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35435725/