def parse_xml(self, xml):
        try:
            parsed = xmltodict.parse(xml, encoding="iso-8859-1")
        except Exception as e:
            logger.debug(
                "Cannot parse the returned xml '{0}' -> '{1}'".format(xml, e))
            parsed = {}

        if 'errors' in parsed:
            self.errors = parsed['errors']['error']
            return

        session = parsed.get('session', {})
        self.session_id = session.get('id')
parse returned data
dataset/ETHPy150Open rochacbruno/python-pagseguro/pagseguro/__init__.py/PagSeguroCheckoutSession.parse_xml