Adding optional writing of xml elements.