views:

34

answers:

1

Hi,

I have a XML file which contains the following:

<config>
  <webservices>
     <webservice>
       <name>A</name>
       <value>http://www.123.com&lt;/value&gt;
     </webservice>
     <proxy enabled="false" useiedefault="false">
       <name>
       </name>
       <value>
       </value>
     </proxy>
  </webservices>
</config>

Is there a way to change the values of 'webservice value' (from the XML file) through textbox in C# and save/update it afterwards?

TextBox1.Text = "http://www.abc.com";
// change value of xml
+1  A: 

This code fragment should work, where fileName is the full path to your XML file:

var doc = new XmlDocument();
doc.Load(fileName);
var node = doc.SelectSingleNode(@"config/webservices/webservice/value");
node.InnerText = TextBox1.Text;
doc.Save(fileName);
Alex Humphrey