As seen in the previous recipes, Akka HTTP has great integration for marshaling and unmarshaling. In the previous recipe, we saw how Akka HTTP can easily marshall and unmarshall JSON, thanks to Spray-json
. The same is true with XML, thanks to Scala XML. Scala XML is a library that was initially part of the core Scala libraries but was later separated. Scala XML has an idiomatic API to write XML directly in your Scala code.
In this recipe, we will see how to easily integrate scala-xml
dependency into our application to serialize and deserialize classes into and from XML.
To step through this recipe, we need to import the Hello-Akka
project and the required Akka HTTP dependency we added in the previous recipe. Also, we will include the required scala-xml
dependency.