[FRPythoneers] xml woes

Matt Gushee mgushee at havenrock.com
Fri Sep 6 11:30:24 MDT 2002

On Fri, Sep 06, 2002 at 11:06:23AM -0600, Evelyn Mitchell wrote:
> * On 2002-09-06 16:25 Karl Putland <karl at putland.linux-site.net> wrote:
> > Days of pain later and still searching for the answer.
> Can you show us the code?

What she said. A little more about your objectives would be helpful,

On Fri, Sep 06, 2002 at 10:23:51AM -0600, Karl Putland wrote:
> Days of pain later and still searching for the answer.
> Trying to create a document using xml.dom.minidom or anything that will
> work.  Not from an existing document, but from scratch.
> Problem is, that I can't get the <!DOCTYPE ...> tag to print out.
> How in the world does this work?

I don't think it does, not with minidom anyway. As the name implies (or
is supposed to), minidom is an 80/20 solution, and it deliberately
provides minimal support for doctypes. Offhand, the solutions I can think
of are to

  * use 4DOM, if performance isn't critical and you don't mind using
    legacy libraries. ex:

      from xml.dom import getDOMImplementation
      impl = getDOMImplementation('4DOM')   # need PyXML for this
      doc = impl.createDocument(spam, eggs, MyDocType)

  * hack minidom to print out the doctype. I think this would be a
    reasonable task to attempt. The reason it doesn't get printed is
    that toprettyxml() only deals with child nodes of the document node,
    and the doctype isn't included in the child nodes. 

Matt Gushee
Englewood, Colorado, USA
mgushee at havenrock.com

More information about the FRPythoneers mailing list