Q:

Boxes and XML in Format module

I would like to print an output using boxes and XML in Format module.
An idea format is as follows:
<Events>
   <Event>
      <name> haha </name>
      <name> haha </name>
   </Event>
   <Event>
      <name> lili </name>
      <name> lili </name>
   </Event>
   <Event>
      <name> lolo </name>
      <name> lolo </name>
   </Event>
</Events>

At the moment my code is as follows, it does not print exactly what I expect (I omit to put the incorrect result here).
  (* in event.ml *)
  let print_name (fmt: formatter) (x: t) : unit =
    Format.open_tag "Name";
    Format.fprintf fmt "%s" (get_name x);
    Format.close_tag ()

  (* in events.ml *)
  let print (fmt: formatter) (x: t) : unit =
    let print (fmt: formatter) (x: t) : unit =
      List.iter
      (fun m ->
         Format.open_tag "Event";
         Format.fprintf fmt "@,@[<v 4>%a@,%a@," Event.print_name m 
                                     Event.print_name m; (* print twice *)
         Format.close_tag ();
         Format.fprintf fmt "@,@]")
      x
    in
    Format.open_tag "Events";
    Format.fprintf fmt "@,@[<v 4>%a@]@," print x;
    Format.close_tag ()

    (* in main.ml *)
    Format.fprintf Format.std_formatter "%a" Events.print x

I am not sure I understand well the box, especially when XML is involved. Does anyone know how to write these formats correctly? 

A:

Format is useful to print data with indentation, but its indentation algorithm is a bit tricky and is hard to simulate other indentation policies perfectly.  Maybe it is easier to handle indentation levels by yourself.

