Write XML to file