XML root node attributes
mmitchell at transparent.com
Tue Nov 17 15:40:36 CET 2009
The information contained in this electronic message and any attached document(s) is intended only for the personal and confidential use of the designated recipients named above. This message may be confidential. If the reader of this message is not the intended recipient, you are hereby notified that you have received this document in error, and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify sender immediately by telephone (603) 262-6300 or by electronic mail immediately. Thank you.
From: python-list-bounces+mmitchell=transparent.com at python.org
[mailto:python-list-bounces+mmitchell=transparent.com at python.org] On
Behalf Of Slafs
Sent: Tuesday, November 17, 2009 9:20 AM
To: python-list at python.org
Subject: XML root node attributes
I'm little confused about adding attributes to the root node when
creating an XML document.
Can I do this using minidom or something else.
I can't find anything that would fit my needs.
i would like to have something like this:
<?xml ... ?>
<root a="v" b="v2" c="v3">
<d ... > </d>
I'm sure someone will point out a better way to do it but yes, you can
do it with minidom.
from xml.dom.minidom import Document
doc = Document()
root = doc.createElement('root')
d = doc.createElement('d')
More information about the Python-list