Created
March 4, 2021 07:43
-
-
Save ivanisidrowu/db0860ff136282a9be13affd8b88a28d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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