title: Python xml.dom.minidom removeChild whitespace problem
body: <p>I'm trying to read an xml file into python, pull out certain elements from the xml file and then write the results back to an xml file (so basically it's the original xml file without several elements). When I use .removeChild(source) it removes the individual elements I want to remove but leaves white space in its stead making the file very unreadable. I know I can still parse the file with all of the whitespace, but there are times when I need to manually alter the values of certain element's attributes and it makes it difficult (and annyoing) to do this. I can certainly remove the whitespace by hand but if I have dozens of these xml files that's not really feasible.</p>
  
  <p>Is there a way to do .removeChild and have it remove the white space as well?</p>
  
  <p>Here's what my code looks like:</p>
  
  <pre><code>dom=parse(filename)
  main=dom.childNodes[0]
  sources = main.getElementsByTagName("source")
  for source in sources :
      name=source.getAttribute("name")
      spatialModel=source.getElementsByTagName("spatialModel")
      val1=float(spatialModel[0].getElementsByTagName("parameter")[0].getAttribute("value"))
      val2=float(spatialModel[0].getElementsByTagName("parameter")[1].getAttribute("value"))
      if angsep(val1,val2,X,Y)&gt;=ROI :
          main.removeChild(source)
      else:
          print name,val1,val2,angsep(val1,val2,X,Y)
  f=open(outfile,"write")
  f.write("&lt;?xml version=\"1.0\" ?&gt;\n")
  f.write(dom.saveXML(main))
  f.close()
  </code></pre>
  
  <p>Thanks much for the help. </p>