code: def save(self, fname):
          
          out = etree.tostring(self.root, xml_declaration=True,
                               standalone=True,
                               pretty_print=True)
          with open(fname, 'wb') as fid:
              fid.write(out)
docs: Save figure to a file