Slafs, 17.11.2009 15:19: > 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.
Yes, you /can/, but you /should/ use 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> > .... > </root> Use ElementTree: import xml.etree.ElementTree as ET root = ET.Element("root", dict(a='v', b='v2', c='v3')) root.SubElement('d') print ET.tostring(root) Stefan -- http://mail.python.org/mailman/listinfo/python-list