Pythonic way to build xml files