print_escaped_for_xml() reformats the <BR>s which were inserted by
G_str_replace() into "<BR>".
any ideas? Use G_tokenize() with '\n' as the field sep?
Add e.g. "char *escape_xml(const char *)" which returns either its
argument or a dynamically-allocated copy with &<> replaced. Apply that
first, then apply G_str_replace() to the result, then print that.
I wouldn't worry about free()ing the result, as this will only be
applied to a relatively limited amount of data.