Having trouble writing XML in Python
<p>I have a XML file that I read with Python. I want to make some changes in the XML file and write it back out.</p>

<p>Here is my code:</p>

<pre><code>from xml.dom.minidom import *

filename = "file.xml"

dom = xml.dom.minidom.parse(filename)

dicts = dom.getElementsByTagName("dict")

for dict in dictList:  
    keys = dict.getElementsByTagName("key")
    for key in keys:
        keyCData = key.firstChild.wholeText
        if keyCData == "kind":
            print keyCData #prints "kind"
            key.firstChild.wholeText = "new text" 
            print key.firstChild.wholeText #prints "new text"

f = open("temp.xml", 'w')
dom.writexml(f)
f.close()
</code></pre>

<p>When I open "temp.xml" to look at though, all my elements with the "key" tag still have their CData as "kind" instead of "new text". So how do I get the new data to be written out to the file?</p>
