How it works...
In this recipe, you learned how to marshal and unmarshal Scala classes into and from XML. For this purpose, we used both Scala XML and akka-http-xml. Unlike the approach with spray-json, this time we had to code the marshalers and unmarshalers ourselves. It is possible to use other Scala XML tools, such as scalaxb, to generate code that creates these marshallers for you; however, this is outside the scope of this recipe.
The ScalaXmlSupport trait has functionality to transform objects from NodeSeq to XML and from XML to NodeSeq. This is the reason why we needed to provide code to transform the NodeSeq instances into our Order and GrandTotal objects. To achieve this seamlessly, we defined implicit conversion through the grandTotalToXML ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access