On 2 June 2011 09:07, Richard Plangger <Richard.Plangger@gmx.net> wrote:
then how would i put something like Ü into my xml file? cause it converts it to Ü all the time. (not just 220)
You need to add the equivalent unicode character to the tree (lxml will only decode the input when parsing.) For Ü that would be u''\u00dc" (as 220 in decimal is dc in hexidecimal). Character references are converted as part of parsing a document by lxml. If you want them in your output then you must serialise the document in an encoding that cannot natively represent those characters, e.g. ascii, using etree.tostring(document, encoding="ascii"). You can get the same effect by calling .encode('ascii', 'xmlcharrefreplace') on the equivalent unicode. Laurence