Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package tw.invictus.tryrss
import tw.ktrssreader.annotation.RssRawData
import tw.ktrssreader.annotation.RssTag
@RssTag(name = "channel")
data class Channel(
val title: String?,
val description: String?,
@RssTag(name = "item")
val items: List<Item>
)
@RssTag(name = "item")
data class Item(
val title: String?,
@RssRawData(rawTags = ["dc:creator"])
val creator: String?,
val pubDate: String?
)
// Then, rebuild your project in intellij!!!!
// Use the generated parser to do the job. :)
@Test
fun `Test jetbrains rss custom feed`() {
val xmlString = getXmlString("https://blog.jetbrains.com/feed/")
// The generated ChannelParser will be in the package of tw.ktrssreader.generated.
val rssModel = ChannelParser.parse(xmlString)
rssModel.items?.forEach {
println(it.title)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment