I am generating XML data that I need to write to an XML file and store in a directory on the server, making it accessible for future use. What is the best approach for writing this data to an XML file, and which directory on the server would be most appropriate for storing such files?