type xml = Tag of string * xml list | String of string let tag name body = Tag (name, body) let format, format_list = Format.(fprintf, pp_print_list) let rec format_xml f = function | Tag (name, body) -> let format_body = format_list format_xml in format f "@[<%s>@,%a@;<0 -3>@]" name format_body body name | String text -> format f "%s" text