import re


def convert_to_prettyprint(xmlstr):
    """
    Convert XML to pretty print for older python versions (< 2.7).
    :param xmlstr: input XML string
    :return: XML string (pretty printed)
    """

    text_re = re.compile(r'>\n\s+([^<>\s].*?)\n\s+</', re.DOTALL)  # Python 3 (added r)
    return text_re.sub(r'>\g<1></', xmlstr)