Hi guys, Sorry, just noticed this now:
I would like my documents to start with the processing instruction so I can specify encodings other than UTF-8.
Hmm, I didn't verify this, although I actually thought lxml produced a declaration here. If not, this should be considered a bug, as it is likely inconsistent with ElementTree. I guess this is the same problem as for tostring(), which only started having the expected behaviour fairly recently.
I disagree on your last point - I think tostring's utility comes from it's standalone nature - i.e. no XML declaration, PIs etc. While I think the write/write_c14n methods on an ElementTree should produce the PIs (XML declaration included) I do not think that simple Element serialisation should include an XML declaration. I am not sure about how other people use it, but in my case I am using etree.tostring to generate and analyse XML fragments in isolation - I would not want an XML declaration messing things up. I intend to post some code to this list in the next few days, which by coincidence will demonstrate my particular use case for tostring. I hope this makes sense. Thanks, Noah -- "Creativity can be a social contribution, but only in so far as society is free to use the results." - R. Stallman