title: Replace Data in XML in vb.net
body: <p>We have a tool that is used to update variables in XML files automatically. I am trying to create a new tool that will change those variables. I've found ways to replace nodes, but I can't find a way to change the ReplaceWith value under a specific name.  E.g., Replace $VariableThree with  value of 20.</p>
  
  <pre><code>&lt;Variables&gt;
      &lt;Variable&gt;
        &lt;Name&gt;$VariableOne&lt;/Name&gt;
        &lt;ReplaceWith&gt;10&lt;/ReplaceWith&gt;
      &lt;/Variable&gt;
      &lt;Variable&gt;
        &lt;Name&gt;$VariableTwo&lt;/Name&gt;
        &lt;ReplaceWith&gt;Name&lt;/ReplaceWith&gt;
      &lt;/Variable&gt;
          &lt;Variable&gt;
        &lt;Name&gt;$VariableThree&lt;/Name&gt;
        &lt;ReplaceWith&gt;10&lt;/ReplaceWith&gt;
      &lt;/Variable&gt;
  </code></pre>
  
  <p>Private Sub UpdateAttribute(ByVal FileName As String, ByVal attrValue As String, ByVal NewValue As String)</p>
  
  <pre><code>    Dim configXml = New XmlDocument
      Dim attr As XmlAttribute
  
      configXml.Load(FileName)
      attr = configXml.SelectSingleNode("/configuration/appSettings/add[@Name = '" &amp; attrValue &amp; "']/@value")
      attr.Value = NewValue
      configXml.Save(FileName)
  
  End Sub
  
  FileName = XML Location
  attValue = Name of the Attribute
  NewValue = the newer value
  </code></pre>