string file = @"c:\bb.xml"; // declearation // parent node XmlElement subnode = xdoc.CreateElement("subnode"); // Checking File Exist or not if (File.Exists(file)) { xdoc.Load(@"C:\bb.xml"); xdoc.DocumentElement.AppendChild(userinfo(txtuser.Text, txtpass.Text)); xdoc.Save(file); } else { subnode.AppendChild(userinfo(txtuser.Text, txtpass.Text)); xdoc.AppendChild(subnode); xdoc.InsertBefore(xdoc.CreateXmlDeclaration("1.0", "utf-8", null), subnode); xdoc.Save(file); } // then create the xml node using this methods XmlNode node = xdoc.CreateElement("Info"); XmlNode user_node = xdoc.CreateElement("user"); user_node.InnerText = user.ToString(); node.AppendChild(user_node); XmlNode pass_node = xdoc.CreateElement("password"); pass_node.InnerText = pass; node.AppendChild(pass_node); return node;
JavaScript
Tuesday, 30 April 2013
Create XML file usign C# and then create sub node in existing file
Subscribe to:
Posts (Atom)