anchor.diff:  %% Created : 16 February 2010
   %%----------------------------------------------------------------------
   -module(ct_config_xml).
  --export([read_config_file/1, list_to_term/1]).
  +-export([read_config_file/1]).
   
  +% the only function to be called outside
   read_config_file(ConfigFile) ->
       case catch do_read_xml_config(ConfigFile) of
   	{ok, Config}->
  
positive.code: 	    {error, Error, ErroneousString}
      end.
  
  do_read_xml_config(ConfigFile)->
      {ok, EntityList, _}=
  	xmerl_sax_parser:file(ConfigFile,
  	    [{event_fun, fun event/3},
  	    {event_state, initial_state()}]),
      {ok, transform_entity_list(EntityList)}.
  
  
  initial_state() ->
      [].
  
  event(Event, _LineNo, State) ->
      tag(Event, State).
  
  tag(startDocument, State) ->
      State;
  
  tag(endDocument,  {_Tags, Result}) ->
      Result;
  
  tag({startElement, _Uri, "config", _QName, _Attributes}, []) ->
  	[{"config", []}];
  
  tag({endElement, _Uri, "config", _QName}, [{"config", Config}]) ->
  	Config;
  
  tag({startElement, _Uri, Name, _QName, _Attributes}, Tags) ->
  	[{Name, []}|Tags];
  
  tag({endElement, _Uri, _Name, _QName},
          [Entity, {PrevEntityTag, PrevEntityValue}|Tags]) ->
  	NewHead = {PrevEntityTag, [Entity|PrevEntityValue]},
  	[NewHead|Tags];
  
  tag({characters, String}, [{Tag, _Value}|Tags]) ->
  	[{Tag, String}|Tags];
  
  tag(_El, State) ->
  	State.
  
  transform_entity_list(EntityList)->
      lists:map(fun transform_entity/1, EntityList).
  
  transform_entity({Tag, [Value|Rest]}) when
      is_tuple(Value)->
  	{list_to_atom(Tag), transform_entity_list([Value|Rest])};
  
negative.code: 	     throw(Error)
      end.
  
  % transform a string with Erlang terms to the terms
  % stolen from trapexit.org :-)
  list_to_term(String) ->
      {ok, T, _} = erl_scan:string(String++"."),
      case erl_parse:parse_term(T) of
  