[Tutor] Problems with creating XML-documents

Karjer Jdfjdf karper12345 at yahoo.com
Wed Apr 14 22:16:02 CEST 2010

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' + \

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()

Can anybody point me in the rght direction or is there another library that I can use to create valid XML-documents?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100414/42ac7a61/attachment.html>

More information about the Tutor mailing list