Utils: changes to record_add_field, better XML handling.

Co-authored-by: Georgios Papoutsakis <georgios.papoutsakis@cern.ch>