Skip to content

Instantly share code, notes, and snippets.

View novakov-alexey-zz's full-sized avatar
🎸
FP user

Alexey Novakov novakov-alexey-zz

🎸
FP user
View GitHub Profile

From scala.xml.pull to javax.xml.stream.events

Want to process XML that's too large to fit in memory?

The Scala standard library used to offer scala.xml.pull for this. It became part of the scala-xml library when scala-xml became separate. But then scala.xml.pull got deprecated (in scala.xml 1.1.1) and finally removed entirely (in scala-xml 2.0.0-M1). The recommended replacement is javax.xml.stream.events.

I had some old code that used scala.xml.pull to digest my iTunes Music Library.xml and print various statistics. Recently I converted it to Scala 3, so I decided to get off the deprecated API at the same time.

So, here is the before-and-after. Perhaps this will help other users of scala.xml.pull who want to convert.