On Sat, Jun 29, 2019 at 04:41:32PM -0400, [hidden email] wrote:
> Can anyone suggest a way to convert Erlang records to XML?
Off the shelf, nothing I'm aware of.
> I can find many ways to go from XML to Erlang, but not the reverse.
Well there's a bunch of different XML libraries for XML. xmerl, for
example, is a part of the standard erlang distribution, and is able to
serialise to XML. There's an example  in the xmerl docs. (The
others should also be able to do it, but I only checked xmerl).
If you want a function that takes an erlang record and outputs some
kind of XML structure, then you're probably going to be disappointed.
Remember that records are mostly a funny compile-time syntax for
tuples, and that the names are (mostly) lost at runtime. You're going
to have to build the internal data structures that your chosen XML
library uses, then serialise from those.
Alternatively, if you don't want to be able to read the XML you're
writing, and it's not a massively complicated structure, it's usually
fairly simple to just build the XML directly.