1

I am trying since last two day for parsing the rss feed of my website using Retrofit and retrofit2.converter.simplexml. It's parsing the basic tag but not like content:encoded etc. I am posting the rss xml LINK OF RSS and retrofit's code here. The problem is this is not parsing content:encoded and category. Retrofit

retrofit = new Retrofit.Builder()
                    .baseUrl(EndPoints.BASE_URL)
                    .client(client)
                    .addConverterFactory(SimpleXmlConverterFactory.create())
                    .build();

POJO classes

@Root(name = "rss", strict = false)
class RssFeed {
    @Element
    var channel: RssChannel? = null
    override fun toString(): String {
        return "RssFeed [channel=$channel]"
    }
}

@Root(name = "channel", strict = false)
class RssChannel {
    @Element
    private val title: String? = null

    @Element
    private val image: RssImage? = null

    @ElementList(inline = true, required = false)
    var item: List<RssItem>? = null
    override fun toString(): String {
        return "Channel [image=$image, item=$item]"
    }
}

@Root(name = "item", strict = false)
class RssItem {

    @Element
    var title: String? = null

    @Element
    var link: String? = null

    @Element
    var pubDate: String? = null

    @Element
    var description: String? = null

    var imageUrl: String? = null

    @Element
    var category: String? = null

    @Element(name = "content", required = true, type = String::class)
    var content: String? = null


    override fun toString(): String {
        return ("RssItem [title=" + title + ", link=" + link + ", pubDate=" + pubDate
                + ", description=" + description + "content=" + content + "]")
    }
}

@Root(name = "image", strict = false)
class RssImage {
    @Element
    private val url: String? = null

    @Element
    private val width: String? = null

    @Element
    private val height: String? = null
    override fun toString(): String {
        return "RssImage [url=$url, width=$width, height=$height]"
    }
}

Category error is

onFailure(java.lang.RuntimeException: org.simpleframework.xml.core.PersistenceException: Element 'category' is already used with @org.simpleframework.xml.Element(data=false, name=, required=true, type=void)
Codingnation
  • 77
  • 1
  • 6

0 Answers0