Moved xml creation logic into single file