How to parse the media:thumbnail url value from an RSSItem using simpleXml?
Here is my RSSItem class:
@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:
<media:thumbnail url="https://tctechcrunch2011.files.wordpress.com/2016/12/gettyimages-591407481.jpg" />
You need to use @Attribute annotation to get this.
In
<media:thumbnail ...>
, the media is a namespace and you only need to use thumbnail to access the content.Example: