title: Python: Appending children to an already created XML file's root using XML DOM
body: <p>I'm totally new to XML and I'm stuck on how to append children to a root node of an already exisitng XML file using Python and XML DOM.  Right now I have this script to create an output file:</p>
  
  <pre><code>from xml.dom.minidom import Document
  
  doc = Document()
  
  root_node = doc.createElement("notes")                          # Root
  doc.appendChild(root_node)
  
  object_node = doc.createElement("data")                         # Child
  root_node.appendChild(object_node)
  
  object_node.setAttribute("a_version", "something_v001.0001.ma") # Set attributes
  object_node.setAttribute("b_user", "Me")
  object_node.setAttribute("c_comment", "comment about file")
  
  xml_file = open("C:/Temp/file_notes.xml", "w")                  # Append
  xml_file.write(doc.toprettyxml())
  xml_file.close()
  </code></pre>
  
  <p>This gives me an output file that looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;notes&gt;
      &lt;data a_version="Me" b_user="something_v001.0001.ma" c_comment="comment about file"/&gt;
  &lt;/notes&gt;
  </code></pre>
  
  <p>I'd like to append future data to this file so it will look something like this after 2 additional versions:</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;notes&gt;
      &lt;data a_version="something_v001.0001.ma" b_user="Me" c_comment="comment about file"/&gt;
      &lt;data a_version="something_v001.0002.ma" b_user="You" c_comment="minor save"/&gt;
      &lt;data a_version="something_v002.0003.ma" b_user="Them" c_comment="major save"/&gt;
  &lt;/notes&gt;
  </code></pre>
  
  <p>But every attempt I make at appending data comes out like this:</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;notes&gt;
      &lt;data a_version="Me" b_user="something_v001.0001.ma" c_comment="comment about file"/&gt;
  &lt;/notes&gt;
  &lt;?xml version="1.0" ?&gt;
  &lt;notes&gt;
      &lt;data a_version="Me" b_user="something_v001.0001.ma" c_comment="comment about file"/&gt;
  &lt;/notes&gt;
  &lt;?xml version="1.0" ?&gt;
  &lt;notes&gt;
      &lt;data a_version="Me" b_user="something_v001.0001.ma" c_comment="comment about file"/&gt;
  &lt;/notes&gt;
  </code></pre>
  
  <p>If anyone has any alternative methods to accomplish this task by using ElementTree that would be appreciated as well.  There seem to be a lot more resources, but I'm not sure how to implement the solution with Maya. Thanks!</p>