In previous posts ([1], [2], [3], [4], [5]), we show how to generate
XML/HTML content using Pythonxml.dom.minidom. Here we will show how to
write the content into a file. The following is the code:
The trick here is in line 5, and lines 19, 20, 21, 22. The library codecs must
be imported to encode the XML file. The lines 19, 20, 21, 22 perform the task
of writing the XML content into a file. It's pretty simple and easy. This again
shows the power and beauty of Python.
In final post [7], we will show how to read a XML file and parse the content.