The documentation is out of date. Use the source, Luke. I do it something like this.
from xml.dom.minidom import DOMImplementation imp = DOMImplementation() doctype = imp.createDocumentType( qualifiedName='foo', publicId='', systemId='http://www.path.to.my.dtd.com/my.dtd', ) doc = imp.createDocument(None, 'foo', doctype) doc.toxml()
The following is printed.
<?xml version="1.0" ?><!DOCTYPE foo SYSTEM \'http://www.path.to.my.dtd.com/my.dtd\'><foo/>
Note that the root element is created automatically using createDocument (). In addition, your βsomethingβ has been changed to βfooβ: the DTD must contain the name of the root element itself.
Amos newcombe
source share