title: replacing value of XML file in javascript
body: <p>I load an XML document using XMLHTTPRequest in my js file. the XML file is like below: </p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;RMFSFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;Host&gt;www.example.com&lt;/Host&gt;
    &lt;Port&gt;8888&lt;/Port&gt;   
    &lt;Uri&gt;www.example.com&lt;/Uri&gt;
  &lt;Path&gt;
       &lt;HD&gt;
          &lt;UNC&gt;path1&lt;/UNC&gt;
      &lt;/HD&gt;
      &lt;SD&gt;
         &lt;UNC&gt;path2&lt;/UNC&gt;
      &lt;/SD&gt;
  &lt;/Path&gt;
  </code></pre>
  
  <p>I am now trying to first select Path1, and Path2 nodes, and then <strong>switch</strong> the value of <strong>path1</strong> with the value of <strong>path2</strong>.
  I select the nodes like below:</p>
  
  <pre><code> var firstNode = xmlFile.querySelector('Path&gt;HD&gt;UNC'); \\ I can get the node successfully. 
   var secondNode= xml.querySelector('Path&gt;SD&gt;UNC');  \\ I can get the node successfully. 
  </code></pre>
  
  <p><strong>However</strong>, when I try to replace the values by using the following code: </p>
  
  <pre><code>    xmlFile.replaceChild(secondNode,firstNode) // secondNode, is the new value for first node.
  </code></pre>
  
  <p>I get an error says,"An attempt was made to reference a Node in a context where it does not exist".
  Any Idea where I am doing it wrong?</p>