[XML-SIG] Generating XML from scratch
and-xml at doxdesk.com
Sat Feb 12 15:49:12 CET 2005
John W. Shipman <john at nmt.edu> wrote:
> Look under the last chapter, ``Creating a document from scratch.''
> I use the constructors such as Document() and Element() in that
> minidom version, but now they want me to use the .createElement()
> and other factory methods from the Document object.
They always did - it's the DOM standard. Minidom was just less fussy
about it a long time ago; you're more likely to get errors about it
> I can't instantiate it as a Document object, because then I
> would get an <?xml...?> processing instruction at the top,
> which is not something I want inside the <body> element of
> a web page.
That's not a good reason not to use a Document. An XML serializer *may*
allow a Document to be output without the XML declaration (pxdom
supports the DOM Level 3 LS parameter 'xml-declaration', for example).
Alternatively, just serialise the Document.documentElement or its
children instead of the Document object itself.
> Previously I was getting around this problem by using a
> DocumentFragment object, but such objects in the minidom have an
> .ownerDocument attribute set to None.
A DocumentFragment still has to have an owner Document. Minidom
DocumentFragments only have a null ownerDocument if you have constructed
them wrong, using minidom's own private constructors.
mailto:and at doxdesk.com
More information about the XML-SIG