Getting runtime exception while parsing RSS Feed

RSS Feed Url – https://feeds.simplecast.com/qm_9xx0g

My View Model Class function

fun getXmlRequest(url: String): LiveData<List<NewsXmlCustomModel>> {

        isLoading.postValue(true)

        val liveData = MutableLiveData<List<NewsXmlCustomModel>>()

        val coreAdXMLService = retrofitXML?.client?.create(CoreAdXmlService::class.java)

        coreAdXMLService?.loadNewsResponse(url)?.enqueue(object : Callback<NewsFeedResponseModel> {
            override fun onFailure(call: Call<NewsFeedResponseModel>, t: Throwable) {
                isLoading.postValue(false)
                liveData.postValue(emptyList())
            }

            override fun onResponse(call: Call<NewsFeedResponseModel>, response: Response<NewsFeedResponseModel>) {

                val responseBody: NewsFeedResponseModel? = response.body()

                responseBody?.channel?.item?.let {
                    val list = mutableListOf<NewsXmlCustomModel>()

                    it.forEachIndexed { index, it ->

                        val newsXmlCustomModel = NewsXmlCustomModel()

                        newsXmlCustomModel.type = ""
                        newsXmlCustomModel.title = it.title
                        newsXmlCustomModel.pos = (index % 2).toString()
                        newsXmlCustomModel.pubDate = it.pubDate
                        newsXmlCustomModel.link = it.link
                        newsXmlCustomModel.description = it.description
                        newsXmlCustomModel.descriptionLink = it.link

                        val xml = "<root>${it.description}</root>"
                        val doc: Document? =
                            try {
                                DocumentBuilderFactory.newInstance()
                                    .newDocumentBuilder()
                                    .parse(InputSource(StringReader(xml)))
                            } catch (e: java.lang.Exception) {
                                logReport(e.message)
                                null
                            }

                        val errNodes: NodeList? = doc?.getElementsByTagName("root")

                        val node: Node? = errNodes?.item(0)
                        if (node != null) {
                            if (node.hasChildNodes()) {

                                val child: Node? = node.firstChild
                                val value: String? = child?.childNodes?.item(0)?.nodeValue?.let {
                                    it.replace("<.*?>".toRegex(), "")
                                } ?: run {
                                    it.description?.replace("<.*?>".toRegex(), "")
                                }

                                newsXmlCustomModel.desc = value
                            }
                        } else {
                            val pattern: Pattern = Pattern.compile("<p>(.+?)</p>", Pattern.CASE_INSENSITIVE)
                            val matcher: Matcher = pattern.matcher(it.description)
                            matcher.find()
                            newsXmlCustomModel.desc =
                                try {
                                    matcher.group(1)
                                } catch (e: Exception) {
                                    it.description?.replace("<.*?>".toRegex(), "") ?: ""
                                }
                        }

                        var imageUrl = ""
                        if (it.description?.contains("<img") == true) {
                            val str: List<String>? = it.description?.split("src=")?.getOrNull(1)?.split(""")
                            imageUrl = str?.getOrNull(1) ?: ""
                        }
                        if (imageUrl == "") {
                            imageUrl = it.enclosure?.url ?: ""
                        }



                        newsXmlCustomModel.imageLink = imageUrl
                        newsXmlCustomModel.contentImg = imageUrl

                        list.add(newsXmlCustomModel)
                    }
                    isLoading.postValue(false)
                    liveData.postValue(list.toList())
                } ?: run {
                    isLoading.postValue(false)
                    liveData.postValue(null)
                }
            }

        })
        return liveData
    }

Model Class

package com.my.appy


import androidx.annotation.Keep
import org.simpleframework.xml.Attribute
import org.simpleframework.xml.Element
import org.simpleframework.xml.ElementList
import org.simpleframework.xml.Root
import java.io.Serializable



@Root(name = "news", strict = false)
class NewsFeedResponseModel : Serializable {
    @set:Element(name = "channel", required = false)
    @get:Element(name = "channel", required = false)
    var channel: NewsFeedChannel? = null

}


@Root(name = "channel", strict = false)
class NewsFeedChannel : Serializable {
    @set:Element(name = "title", required = false)
    @get:Element(name = "title", required = false)
    var title: String? = ""

    @set:ElementList(inline = true, name = "item", required = false)
    @get:ElementList(inline = true, name = "item", required = false)
    var item: ArrayList<NewsFeedItem>? = null

}

@Root(name = "item", strict = false)
class NewsFeedItem : Serializable {
    @set:Element(name = "title", required = false)
    @get:Element(name = "title", required = false)
    var title: String? = ""

    @set:Element(name = "description", required = false)
    @get:Element(name = "description", required = false)
    var description: String? = ""

    @set:Element(name = "pubDate", required = false)
    @get:Element(name = "pubDate", required = false)
    var pubDate: String? = ""

    @set:Element(name = "link", required = false)
    @get:Element(name = "link", required = false)
    var link: String? = ""

    @set:Element(name = "image", required = false)
    @get:Element(name = "image", required = false)
    var image: NewsImageSourceAttribute? = null


    @set:Element(name = "enclosure", required = false)
    @get:Element(name = "enclosure", required = false)
    var enclosure: NewsEnclosureImageSourceAttribute? = null

    @set:Element(name = "media", required = false)
    @get:Element(name = "media", required = false)
    var media: String? = "123"
}


@Root(name = "description", strict = false)
class NewsImageSourceAttribute : Serializable {
    @set:Attribute(name = "img", required = false)
    @get:Attribute(name = "img", required = false)
    var img: NewsImgSourceAttribute? = null
}


@Root(name = "enclosure", strict = false)
class NewsEnclosureImageSourceAttribute : Serializable {
    @set:Attribute(name = "url", required = false)
    @get:Attribute(name = "url", required = false)
    var url: String? = ""
}


@Root(name = "img", strict = false)
class NewsImgSourceAttribute : Serializable {
    @set:Attribute(name = "src", required = false)
    @get:Attribute(name = "src", required = false)
    var img: String? = ""
}

Getting Error

Updated syntax of Element annotation to avoid exception – java.lang.RuntimeException: org.simpleframework.xml.core.PersistenceException: Element ‘title’ is already used with @org.simpleframework.xml.Element(data=false, name=title, required=false, type=void) on method ‘title’ at line 41

Tried parsing but getting Runtime exception. I have tried different solutions on stack overflow but they are not working for my case.

Thanks

New contributor

Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật