I'm having problems with creating XML-documents, because I don't seem to write it to a document correctly. I have to write the document from a loop:
doc.write('<?xml version="1.0" encoding="iso-8859-1"?>\n') .... for instance in query: if doc != None: text = str('<record id="' + str(instance.id)+ '">\n' + \ ' <date>' + str(instance.datetime) + ' </date>\n' + \ ' <order>' + instance.order + ' </order>\n' + \ '</record>\n') doc.write(text) When I try to parse it, it keeps giving errors. So I tried to use an external library jaxml, but I don't know how to implement this in the loop because the output is written at the end (doc._output) and I overwrite my values. The code below is from the jaxml website # an equivalent version using JAXML import jaxml doc = jaxml.XML_document() doc.sometag(someattr=1).anothertag(jaxml="Nice") doc.thirdone("Yo") doc._output("sample.xml") Can anybody point me in the rght direction or is there another library that I can use to create valid XML-documents?
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor