Hi Peter,
line is missing in the output. I have figured out that it can be added via the commented out output statement in the python code as long as I know (or assume I know) what the encoding was, but I would prefer to copy the values from the input line through (which is what the perl bindings do). Is there a way to do that that I'm not finding?
The XML data is basically unicode and encoded during the write with the encoding requested. Because of that, the decoding during the read is independent of the encoding on write. However, you can get all information in the xml declaration from the parsed XML:
x = etree.parse('/tmp/test.xml')
x.docinfo.encoding 'utf-8’
x.docinfo.standalone False
x.docinfo.xml_version '1.0'
x.write('/tmp/2.xml', encoding='UTF-16')
y = etree.parse('/tmp/2.xml')
y.docinfo.encoding 'UTF-16’
Then the pretty printing has failed on the name space xml at the top of the file (possibly because I haven't done something necessary to register the name spaces?)
The exact arrangement of whitespace between attributes is not saved, as far as I know, and because of that, pretty print does not arrange attributes in a special way, it just indents the elements. jens