XML with Python - supposed to be simple? ;)

Martin v. Loewis martin at v.loewis.de
Sun Jul 21 16:36:21 EDT 2002


"Vladimir Cherepanov" <vovka_foreverREMOVE_THIS at hotmail.com> writes:

> As a complete newbie to both XML and Python, I've been trying to
> create (any!) XML document using DOM API in PyXML package. Very
> simple task isn't it?

No, XML is difficult; it becomes more difficult the closer you get to
it.

Creating documents with DOM is indeed tricky. I recommend that you use
plain print statements, like

print "<foo/>"

which creates a nicely well-formed XML document.

If you insist on using the DOM, I recommend that you read the DOM spec
first (from www.w3.org). You'll then learn that you can create
Document instances by invoking createDocument on the
DOMImplementation. For minidom, you get the DOM implementation by
calling xml.dom.minidom.getDOMImplementation().

Regards,
Martin



More information about the Python-list mailing list