records in text files or configuration

Richard Carlsson <>
Thu Aug 5 23:23:35 CEST 2004


Fredrik Thulin wrote:

> I guess I'll have to invent myself some kind of plain text format that 
> is reasonably easy to modify and still easily parseable. Too bad, I'll 
> have to deal with quoting and stuff which would otherwise have been 
> handled for me.

You won't have to do any text parsing if you use Erlang terms as your
representation, e.g.:

[{contact, [{name, "Fredrik Thulin"},
             {email, ""}]
  },
  ...].

You can still read this using consult(), and it's easy to write a
function that translates between the internal representation and
such an explicit keyword/value representation.

Or for interoperability with other things as well, use XMerL.
It allows you to (among many other things) take a list as the above
and have it automatically output as

<contact><name>"Fredrik Thulin"</name>
          <email>""</email>
</contact>
...

and reversely you can easily read the XML file and get it in
the same simple list representation again.

   http://sowap.sourceforge.net/

	/Richard






More information about the erlang-questions mailing list