I have a few scattered links that can help you get started.
xmerl is not very intuitive for a newcomer so I see some cursing in your future.
Notes on xmerl and processing XML in Erlang. This one can help you understand how can you construct
:xmerl XML nodes programmatically (as opposed to receiving them when stream-parsing a file) – and then stream them to a destination file. You’ll likely have to learn to import and use Erlang records in Elixir at some point – but mind you, this is only for reading Erlang records from Elixir, not for writing them.
It’s quite simple:
Record.extract(:xmlElement, from_lib: "xmerl/include/xmerl.hrl")
Read more about it:
Two blog articles on stream-reading XML files. You’ll need these even if you only write XML:
- SAX Xml parsing in Erlang – Part 1
- A Simple XML State Machine Accepting SAX Events to Build xmerl Compitable XML Tree: icalendar demo
xmerl's docs on the various hook functions that you can pass to its processors (trust me, you’ll need some of these as well, depending on the complexity of your task):
xmerl works by accumulating XML elements / texts / namespaces etc. in a reverse-accumulator manner (prepending elements to a list; at least that’s how it works when stream-parsing and processing-as-you-go – haven’t checked the writing functionality for that idiom), using its own in-memory representation of XML. Which you can then pass to its export functions if you want a file (or only a singular XML element serialised to a charlist).
As I said before, it’s going to be a ride.