[英]Android RSS reader using SimpleXml and Retrofit - media:thumbnail parse issue
How to parse the media:thumbnail url value from an RSSItem using simpleXml? 如何使用simpleXml从RSSItem解析media:thumbnail url值?
Here is my RSSItem class: 这是我的RSSItem类:
@Root(name = "item", strict = false)
public class FeedItem {
@Element(name = "pubDate")
private String pubDate;
@Element(name = "title")
private String title;
@Element(name = "link")
private String link;
@Element(name = "description")
private String description;
public FeedItem() {
}
public FeedItem(String description, String link, String title, String pubDate) {
this.description = description;
this.link = link;
this.title = title;
this.pubDate = pubDate;
}
public String getPubDate() {
return pubDate;
}
public void setPubDate(String pubDate) {
this.pubDate = pubDate;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
it all works ok, but I need to parse also the image url from the xml (media:thumbnail) here: 一切正常,但是我还需要在这里从xml(media:thumbnail)解析图像网址:
<media:thumbnail url="https://tctechcrunch2011.files.wordpress.com/2016/12/gettyimages-591407481.jpg" />
You need to use @Attribute annotation to get this. 您需要使用@Attribute批注来获取此信息。
In <media:thumbnail ...>
, the media is a namespace and you only need to use thumbnail to access the content. 在<media:thumbnail ...>
, 媒体是一个名称空间,您只需要使用缩略图即可访问内容。
Example: 例:
@Element(name = "thumbnail", required = false)
private Thumbnail thumbnail;
@Root(name = "thumbnail", strict = false)
static class Thumbnail {
@Attribute(name = "url")
private String url;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.