from io import StringIO


def to_XML_string(Coalesce_object, indent_level = 1, pretty_print = True):
    """
    Assigns the XML representation of a Coalesce object to a string.

    :param Coalesce_object:  a Coalesce object with an "export" method
    :param level:  multiply by 4 to determine the number of spaces for each
        level of indentation
    :param pretty_print:  if ``True``, add indentation

    :returns:  a Unicode XML string

    """

    # Initialize the StringIO object.
    string_file = StringIO()

    # Export the Coalesce object to the StringIO object as XML.
    Coalesce_object.export(string_file, indent_level,
                           pretty_print = pretty_print)

    # Return the XML as a string.
    return string_file.getvalue()