XML support with Akka HTTP
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.
Getting ready
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.
How to do it...
For this recipe, perform the following steps:
- Get the required dependencies.
- Edit the
build.sbt
file and add theakka-http-xml
dependency as follows:
libraryDependencies...