def prettify ( elem ) : rough_string = ET . tostring ( elem , 'utf-8' ) reparsed = minidom . parseString ( rough_string ) return reparsed . toprettyxml ( indent = "\t" )
get xml element and prettify python
Return a pretty - printed XML string for the Element .
def prettify(elem):
    """Return a pretty-printed XML string for the Element.
    """
    rough_string = ET.tostring(elem, 'utf-8')
    reparsed = minidom.parseString(rough_string)
    return reparsed.toprettyxml(indent="\t")