Hi, I'm looking for your recommendations to parse ...
# announcements
l
Hi, I'm looking for your recommendations to parse a simple xml file that doesn't go deeper than 3 levels. Here's an example of the kind of files I'm going to parse: https://dl.google.com/dl/android/maven2/androidx/lifecycle/lifecycle-runtime/maven-metadata.xml In the end, I want to get a list of the available versions. Is there a light library that I should use, or is that overkill and I should just use Kotlin stdlib to do it? Thanks for your input!
e
Looks like there are some Java libraries built-in that you can leverage: https://stackoverflow.com/a/5059312
l
Thanks for the input. I ended up using the stdlib only to parse the files in a basic but sufficient way with only 4 lines of code: https://github.com/jmfayard/buildSrcVersions/blob/e234168b6dc22b8084fc47d8d8328cb5bf056bac/refreshVersions/src/main/kotlin/de/fayard/versions/LatestVersionRetrieval.kt#L43-L47
m
Ok, good if it works for you, but remember that parsing context-free languages with string search/regex can be brittle, but works for very simple cases
👌 1