added def to write to xml functions (correct previous commit)