Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

I am working on xml

when I add new recoard always replacing 1st record it's not accepting 2nd.. records

my code is

C#
if (File.Exists(path))
            {
                XElement xml = new XElement("Users", new XElement("User", new XElement("UserName", txtUserName.Text),
                    new XElement("Password", txtpassword.Text), new XElement("Role", Role)));
                xml.Save(path);
                MessageBox.Show("Saved");
            }


result is
//this is result
<Users>
  <User>
    <UserName>admin</UserName>
    <Password>admin</Password>
    <Role>Admin</Role>
  </User>
</Users>
//I want below result
<Users>
  <User>
    <UserName>admin</UserName>
    <Password>admin</Password>
    <Role>Admin</Role>
  </User>
<User>
    <UserName>test</UserName>
    <Password>test</Password>
    <Role>User</Role>
  </User>
</Users>
Posted

1 solution

Please look into the below link.

http://www.bassicsoftware.com/popup.aspx?b_id=161[^]

Regards,
Manoj
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900