code: def cleanXml(node):
      ## remove extraneous text; let the xml library do the formatting.
      hasElement = False
      nonElement = []
      for ch in node.childNodes:
          if isinstance(ch, xml.Element):
              hasElement = True
              cleanXml(ch)
          else:
              nonElement.append(ch)
  
      if hasElement:
          for ch in nonElement:
              node.removeChild(ch)
      elif node.tagName == "g":  ## remove childless groups
          node.parentNode.removeChild(node)
  
imports: import contextlib
  import re
  import xml.dom.minidom
  import numpy
  from ..None import PlotCurveItem, ScatterPlotItem, debug
  from ..None import functions
  from ..parametertree import Parameter
  from ..Qt import QtCore, QtGui, QtSvg, QtWidgets
  from .Exporter import Exporter
label_desc: Use image node_id 5 for calling a global function with example usage: cleanXml(node) without return types