prof18 / RSS-Parser

A Kotlin Multiplatform library to parse a RSS Feed
Apache License 2.0
524 stars 128 forks source link

Always get exception RssParsingException #125

Closed GazimSoliev closed 1 year ago

GazimSoliev commented 1 year ago

Describe the bug A clear and concise description of what the bug is. Code:

fun main() {
    runBlocking {
        val test = "https://habr.com/ru/rss/hubs/artificial_intelligence/articles/all/?fl=ru"
        println(test)
        println(RssParser().parse(test))
    }
}

Exception:

Exception in thread "main" RssParsingException(message=Something went wrong during the parsing of the feed. Please double check if the XML is valid, cause=org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.)
    at com.prof18.rssparser.internal.JvmXmlParser$parseXML$2.invokeSuspend(JvmXmlParser.kt:37)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
    at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204)
    at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:178)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1465)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:978)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:542)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:889)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224)
    at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:637)
    at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:326)
    at java.xml/javax.xml.parsers.SAXParser.parse(SAXParser.java:197)
    at com.prof18.rssparser.internal.JvmXmlParser$parseXML$2.invokeSuspend(JvmXmlParser.kt:32)
    ... 8 more

The link of the RSS Feed Please provide a link to the RSS Feed that causes the bug. https://habr.com/ru/rss/hubs/artificial_intelligence/articles/all/?fl=ru https://www.test.de/rss/alles/ https://www.tagesschau.de/index~rss2.xml

GazimSoliev commented 1 year ago

I created new project, it still doesn't work and also checked different RSS links

GazimSoliev commented 1 year ago

Oh, sorry, I didn't notice that I have to use getRssChannel link, I apologize for that

GazimSoliev commented 1 year ago

Oh, sorry, I didn't notice that I have to use getRssChannel link, I apologize for that

if u want u can create wrapper link and wrapper xml for parse and getRssChannel, for example value class RssLink(val url: String)and value class RssXML(val xml: String)