How do i replace a amphersand with the html sign & in a xml document? normally it works simply with
a = u"TORE & Co & KG"
i = a.replace('&','&')
print i
Here it doesn't work:i get my xml structure out of an email and process it like this:
saver=StringIO(u"") # Edit
a=str(msg)
i= a.decode('quopri').decode('utf-8')
saver.write(i)
savercontent = saver.getvalue()
savercontent.replace('&','&')
In the end the replacement dosen't work...no errors..., how can i fix this? I guess this is connected with the encodings/decodings... Any help?
You could try:
a = str(msg)
i = a.decode('quopri').decode('utf-8').replace('&', '&')
saver.write(i)
savercontent = saver.getvalue()
Or try:
i = a.decode('quopri').replace('&', '&').decode('utf-8')
may be change
savercontent.replace('&','&')
to
savercontent = savercontent.replace('&','&')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With