def store_magic_envelope_doc(self, payload):
try:<EOL><INDENT>json_payload = json.loads(decode_if_bytes(payload))<EOL><DEDENT>except ValueError:<EOL><INDENT>xml = unquote(decode_if_bytes(payload))<EOL>xml = xml.lstrip().encode("<STR_LIT:utf-8>")<EOL>logger.debug("<STR_LIT>", xml)<EOL>self.doc = etree.fromstring(xml)<EOL><DEDENT>else:<EOL><INDENT>logger.debug("<STR_LIT>", json_payload)<EOL>self.doc = self.get_json_payload_magic_envelope(json_payload)<EOL><DEDENT>
Get the Magic Envelope, trying JSON first.