code: def _pretty_xml(xml_string):
      
  
      result_dom = minidom.parseString(xml_string)
      pretty_result = result_dom.toprettyxml(indent='  ')
  
      # remove extra empty lines
      return re.sub(r'>( *[\r\n]+)+( *)<', r'>\n\2<', pretty_result)
docs: Common function to produce pretty xml string from an input xml_string.
  
      This function is NOT intended to be used in major code paths since it
      uses the minidom to produce the prettified xml and that uses a lot
      of memory