code: def xmlindent(elem, level=0, spacer='  '):
      
      i = "\n" + level * spacer
      if len(elem):
          if not elem.text or not elem.text.strip():
              elem.text = i + spacer
          if not elem.tail or not elem.tail.strip():
              elem.tail = i
          for elem in elem:
              xmlindent(elem, level + 1)
          if not elem.tail or not elem.tail.strip():
              elem.tail = i
      else:
          if level and (not elem.tail or not elem.tail.strip()):
              elem.tail = i
docs: Indents the inputted XML element based on the given indent level.
      
      :param      elem    | <xml.etree.Element>