Python, XmlrpcLib, ExpatParser and Encodings
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.
About this entry
You’re currently reading “ Python, XmlrpcLib, ExpatParser and Encodings ,” an entry on Chui's Counterpoint
- Published:
- 10.4.07 / 8am
- Category:
- Python
No comments
Jump to comment form | comments rss [?] | trackback uri [?]