title: My VB code appends two nodes instead of only one
body: <p>I have the following XML file</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0"?&gt;
  &lt;Config&gt;
      &lt;ImgFileName&gt;W10-00&lt;/ImgFileName&gt;
      &lt;Index&gt;1&lt;/Index&gt;
      &lt;Diag&gt;0&lt;/Diag&gt;
  &lt;/Config&gt;
  </code></pre>
  
  <p>And I want to add a new node 'CanSS' and make the value = '1'.</p>
  
  <p>This is the code I am calling</p>
  
  <pre class="lang-vb prettyprint-override"><code>Private Sub AddNode(ByVal CFGFile As String, ByVal Node As String, ByVal ValStr As String)
      Dim docXMLDOM As DOMDocument
      Dim nodeRoot As IXMLDOMElement
      Dim nodeNewElement As IXMLDOMElement
  
      ' Initialize the document model
      docXMLDOM = New DOMDocument
  
      ' Open the XML document
      docXMLDOM.load(CFGFile)
  
      ' Get a reference to the root node
      nodeRoot = docXMLDOM.documentElement
  
      nodeNewElement = docXMLDOM.createElement(Node)
      nodeNewElement.text = ValStr
      nodeRoot.appendChild(nodeNewElement)
  
      ' Save the file
      docXMLDOM.save(CFGFile)
  
      docXMLDOM = Nothing
  End Sub
  </code></pre>
  
  <p>which changes my XML to this</p>
  
  <pre class="lang-xml prettyprint-override"><code>    &lt;?xml version="1.0"?&gt;
  &lt;Config&gt;
      &lt;ImgFileName&gt;W10-00&lt;/ImgFileName&gt;
      &lt;Index&gt;1&lt;/Index&gt;
      &lt;Diag&gt;0&lt;/Diag&gt;
  &lt;CanSS&gt;1&lt;/CanSS&gt;&lt;CanSS&gt;1&lt;/CanSS&gt;&lt;/Config&gt;
  </code></pre>
  
  <p>Can anyone see where I'm going wrong?</p>