def prettify_xml(xmlstr):
    """add indentation to create pretty xml"""
    indent = 1
    for i in range(len(xmlstr)):
        item = xmlstr[i]
        if item.startswith('</'):
            indent -= 1
            tag = xmlstr[i - 1].startswith('<')
            yield tag * ' ' * indent * 4 + item + '\n'
        elif item.startswith('<'):
            tag = xmlstr[i + 1].startswith('<')
            yield ' ' * indent * 4 + item + tag * '\n'
            indent += 1
        else:
            yield item
    raise StopIteration()
