Decode base64 string in python 3 (with lxml or not)
I know this looks embarrassingly easy, and I guess the problem is that I just don't have a clear understanding of all this bytes-str-unicode (and encoding-decoding , speaking frankly) stuff yet. I've been trying to get my working code to run on Python 3. The part I'm stuck with is when I parse an XML with lxml and decode a base64 string that is in that XML. The code now works in the following manner: I retrieve the binary data with an XPath query '.../binary/text()' . This produces a one-element list containing a lxml.etree._ElementUnicodeResult object. Then, with python 2, I was able to do: