[XML-SIG] Generating XML from scratch

Mike Hostetler hostetlerm at gmail.com
Wed Feb 9 21:19:52 CET 2005

On Wed, 9 Feb 2005 12:46:19 -0700 (MST), John W. Shipman <john at nmt.edu> wrote:
> I've been all through python.org site and carefully read ``Python
> & XML'' by Jones and Drake, but I can't find any body of practice
> about the generation of XML files from scratch.  All the existing
> practice seems to be about reading or modifying existing XML
> documents.  I want to capture data from a GUI or other source and
> store it as an XML document.

Here is a snippet of how I did it with the Sax parser a few years ago.
 At the time, minidom didn't do all I needed, but in Py > 2.1 minidom
has matured . . .

                from xml.dom.ext.reader import Sax

                dom = Sax.FromXml("<root />")
                assert dom.documentElement.tagName == 'root'

Mike Hostetler

More information about the XML-SIG mailing list