write_metadata function

Creates define XML metadata