def _convert_queue_message_xml(message_text, encode_function, key_encryption_key):
queue_message_element = ETree.Element('<STR_LIT>');<EOL>message_text = encode_function(message_text)<EOL>if key_encryption_key is not None:<EOL><INDENT>message_text = _encrypt_queue_message(message_text, key_encryption_key)<EOL><DEDENT>ETree.SubElement(queue_message_element, '<STR_LIT>').text = message_text<EOL>try:<EOL><INDENT>stream = BytesIO()<EOL>ETree.ElementTree(queue_message_element).write(stream, xml_declaration=True, encoding='<STR_LIT:utf-8>', method='<STR_LIT>')<EOL>output = stream.getvalue()<EOL><DEDENT>finally:<EOL><INDENT>stream.close()<EOL><DEDENT>return output<EOL>
<?xml version="1.0" encoding="utf-8"?>
<QueueMessage>
    <MessageText></MessageText>
</QueueMessage>