[EMAIL PROTECTED] wrote: > I am attempting to create an XML document dynamically with Python. It > needs the following format: > > <zAppointments reminder="15"> > <appointment> > <begin>1179775800</begin> > <duration>1800</duration> > </appointment> > </zAppointments>
Try lxml.objectify. http://codespeak.net/lxml/dev/objectify.html >>> from lxml import etree, objectify >>> zAppointments = objectify.Element("zAppointments") >>> zAppointments.set("reminder", "15") >>> zAppointments.appointment = objectify.Element("appointment") >>> zAppointments.appointment.begin = 1179775800 >>> zAppointments.appointment.duration = 1800 >>> print etree.tostring(zAppointments, pretty_print=True) <zAppointments reminder="15"> <appointment> <begin>1179775800</begin> <duration>1800</duration> </appointment> </zAppointments> Pretty much what one would expect. Stefan -- http://mail.python.org/mailman/listinfo/python-list