The following code causes the well-known "UnicodeDecodeError codec:" ascii "cannot decode" error:
import xml.sax import io parser = xml.sax.make_parser() parser.parse(io.StringIO(u'<a>é</a>'))
While
import xml.sax parser = xml.sax.make_parser() parser.parse(open('foo'))
works (the contents of the file "foo" is <a>é</a>
).
I need to parse an XML string in my case, not a file.
Is there any solution to my problem? Thanks.
source share