Python, XmlrpcLib, ExpatParser and Encodings
Thursday, 4 October 2007
I had to deal with an XMLRPC server that returned data in ‘iso-8859-1′ encoded, but didn’t have the encoding wired into the XML declaration. After some digging around, this hardcoded changes fixed the problem.
class ExpatParser:
# fast expat parser for Python 2.0 and later. this is about
# 50% slower than sgmlop, on roundtrip testing
def __init__(self, target):
src_encoding = 'iso-8859-1'
self._parser = parser = expat.ParserCreate(src_encoding, None)
Hope it’s useful to you.