Skip to content

Saving information with XML in C#

Brandon

Asked Oct 31, 2008, 12:00 AM EDT3 answers
Share
LinkedInX
Okay, here's the deal. I'm writing a program in c# that requires the user to enter information into textboxes. I want the user to be able to click a button and the information is instantly saved into an XML file, to be loaded later. I've found some tutorials on doing this, but the problem is that the ones I found simply add new nodes to an xml file. For example if we have the XML file below:

<login>
  <user>Bob</user>
  <pass>password</pass>
</login>

I want to be able to change the information for <user> and <pass>. The examples that I found all added new nodes onto the file and didn't edit the already existing ones.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • +1
    We have DocumentElement.ChildNodes. ReplceNodeAt().
    As per ur XML
    <user>Bob</User>
    <pass>password</password>

    <user> ---> is ChildElement.
    Bob----> is InnerText.

    here ChldNodes retrives the all the childnodes, if u want to replace that u can Edit or Replace the Inner Text  with Method ReplaceNodeAt()..
    U can thy this....
    +1
  • +1
    Could you show me an example? I'm new to .NET. I'm used to native c code.
    +1
  • 1 short reply
    • +1
      Thanks a lot
      +1