Hi all ,
i want to save different user name and password in single XML file .
for this i wrote this code on save button :-
string filename = "E:\\firstXML.xml"; XmlDocument xmlDoc = new XmlDocument(); XmlTextWriter xmlWriter = new XmlTextWriter(filename, System.Text.Encoding.UTF8); xmlWriter.Formatting = Formatting.Indented; xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); xmlWriter.WriteStartElement("Credential"); xmlWriter.Close(); xmlDoc.Load(filename); XmlNode root = xmlDoc.DocumentElement; XmlElement childNode1 = xmlDoc.CreateElement("UserName"); XmlElement childNode2 = xmlDoc.CreateElement("Password");
root.AppendChild(childNode1); childNode1.InnerText = tbName.Text;
xmlDoc.Save(filename);
USING THIS XML IS CREATING BUT NEXT TIME IF I AM INSERTING DIFFERENT USER NAME AND PASSWORD IT IS REPLACING MY PREVIOUS DATA. HOW TO ADD ALL USER NAME AND PASSWORD INTO SINGLE XML FILE PLEASE HELP..