title: Python Minidom : Change Value of Node
body: <p>I'm using Python's minidom library to try and manipulate some XML files. Here is an example file :</p>
  
  <pre><code>&lt;document&gt;
      &lt;item&gt;
              &lt;link&gt;http://www.this-is-a-url.com/&lt;/link&gt;
              &lt;description&gt;This is some information!&lt;/description&gt;
      &lt;/item&gt;
  
      &lt;item&gt;
              &lt;link&gt;http://www.this-is-a-url.com/&lt;/link&gt;
              &lt;description&gt;This is some information!&lt;/description&gt;
      &lt;/item&gt;
  
      &lt;item&gt;
              &lt;link&gt;http://www.this-is-a-url.com/&lt;/link&gt;
              &lt;description&gt;This is some information!&lt;/description&gt;
      &lt;/item&gt;
  &lt;/document&gt;
  </code></pre>
  
  <p>What I need to do, is take the value in "description" and put it into "link" so both say "This is some information!". I've tried to do it like so:</p>
  
  <pre><code>#!/usr/bin/python
  
  from xml.dom.minidom import parse
  
  xmlData = parse("file.xml")
  
  itmNode = xmlData.getElementsByTagName("item")
  for n in itmNode:
      n.childNodes[1] = n.childNodes[3]
      n.childNodes[1].tagName = "link"
  print xmlData.toxml()
  </code></pre>
  
  <p>However "n.childNodes[1] = n.childNodes[3]" seems to link the two nodes together, so when I do "n.childNodes[1].tagName = "link"" to correct the name BOTH child nodes become "link" where before they were both "description".</p>
  
  <p>Furthermore, if I use "n.childNodes[1].nodeValue" the changes don't work and the XML is printed in it's original form. What am I doing wrong?</p>