title: Saving modified xml error 'ElementTree' object has no attribute 'tag'
body: <p><strong>Code</strong></p>
  <p>When running the following code I cannot save the output as an xml file as I get the following error <strong>AttributeError: 'ElementTree' object has no attribute 'tag'</strong>(in traceback). There is a similarly named question on SO but I do not believe it is relevant to mine as it was to do with parsing from the root node, not saving.</p>
  <p><strong>Code</strong></p>
  <pre><code>import xml.etree.ElementTree as ET
  print('\n'*5)
  
  xmlfile = 'widget.XML'
  
  tree = ET.parse(xmlfile)
  root = tree.getroot()
  
  #ET.dump(tree)# prints the xml file to console,shows xml indentation
  print('\n'*2)
  for elm in root.findall(&quot;./Common/ForceBinary&quot;):
      print(elm.attrib)
      elm.attrib = {'type': 'integer', 'value': '0'}
  
  with open(&quot;new_file.xml&quot;, &quot;w&quot;) as f:
      f.write(ET.tostring(tree))
  </code></pre>
  <p><strong>Traceback</strong></p>
  <pre><code>{'type': 'integer', 'value': '1'}
  Traceback (most recent call last):
    File &quot;/Users/user/Desktop/MY_PY/x_08.py&quot;, line 16, in &lt;module&gt;
      f.write(ET.tostring(tree))
    File &quot;/Users/user/opt/anaconda3/lib/python3.7/xml/etree/ElementTree.py&quot;, line 1136, in tostring
      short_empty_elements=short_empty_elements)
    File &quot;/Users/user/opt/anaconda3/lib/python3.7/xml/etree/ElementTree.py&quot;, line 777, in write
      short_empty_elements=short_empty_elements)
    File &quot;/Users/user/opt/anaconda3/lib/python3.7/xml/etree/ElementTree.py&quot;, line 901, in _serialize_xml
      tag = elem.tag
  AttributeError: 'ElementTree' object has no attribute 'tag'
  </code></pre>