Inserting DTD statement to XML

jakecjacobson at gmail.com jakecjacobson at gmail.com
Wed Mar 19 14:33:19 EDT 2008


I am new to Python and I am writing a script to build a XML document
and post it to a website.  I have a working script but need to insert
a DTD statement in my XML document and can't find out how to do this.
I am using "from xml.dom.minidom import Document"

Some code I am using is:

	doc = Document()
	rootNode = doc.createElement("employees")
	doc.appendChild(rootNode )

I get the following when I print it out

<?xml version="1.0" ?>
<employees>
   ...
</employees>

What I would like is to have something like:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE employees PUBLIC "-//ICES//DTD ICES EMPLOYEES//EN" "">
<employees>
   ...
</employees>




More information about the Python-list mailing list