title: Why does this simple python3 class does not overwrite/modify existing xml file?
body: <p>I have the following simple beginner XML class in python3. Where I just input the name of the xml file and the path to the file as arguments then I just want to append the new contents to the file via overwriting it. I have the following directory tree.</p>
  
  <pre><code>main
  |--data
  |  |--aesxml
  |     |--test.xml
  |--img
  |  |--xmlClass.py
  |  |--test.xml
  </code></pre>
  
  <p>If I run the code for the test.xml located in the same folder it works as intended. However if I run it for the test.xml located in the <code>data</code>folder it still runs without any error but it doesn't write/modify anything in the file.
  I am just beginning to learn xmls in python and quite puzzled in this. Tried adding an <code>encoding='utf-8'</code> to the <code>xmlTree.write()</code> function but it still doesn't do anything.</p>
  
  <pre><code>class TestXML:
  
      def __init__(self,xmlInPath,xmlfile):
          self.inputPath = xmlInPath
          self.fileName = xmlfile
  
      def writeXML(self,newCandidateName,newCandidateCentroid):
          xmlTree = et.parse(self.inputPath+self.fileName)
          root = xmlTree.getroot()
  
          newContest = et.SubElement(root,"contest",attrib={"position":"0"})
          newCandidate = et.SubElement(newContest,"candidate",attrib={"code":"0"})
  
          candidateName = et.SubElement(newCandidate,"name")
          candidateCentroid = et.SubElement(newCandidate,"centroid")
  
          candidateName.text = newCandidateName
          candidateCentroid.text = newCandidateCentroid
  
          xmlTree.write(self.fileName)
  
  
  if __name__ == '__main__':
      xmlTest = TestXML("/home/main/img/","test.xml")
      xmlTest.writeXML("John","(0,1)")
  </code></pre>
  
  <p>Here is the base XML file:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;config title="Test"&gt;
      &lt;contest position="0"&gt;
          &lt;candidate code="0"&gt;
              &lt;name&gt;Mark&lt;/name&gt;
              &lt;centroid&gt;(0,1)&lt;/centroid&gt;
          &lt;/candidate&gt;
      &lt;/contest&gt;
  &lt;/config&gt;
  </code></pre>