This is code Add xml node in configuration file using C# method. Step:1 this is sample.config file
<TABLE> <ROW> <COLUMN SOURCE="1" NAME="age" /> <COLUMN SOURCE="3" NAME="firstname" /> <COLUMN SOURCE="4" NAME="lastname" /> </ROW> </TABLE>
public bool AddconfigFileXmlNode() { try { var doc = new XmlDocument(); doc.Load("D:\\sample.config"); XmlNode profile; profile = doc.SelectSingleNode("TABLE/ROW"); XmlElement newChild = doc.CreateElement("COLUMN"); newChild.SetAttribute("SOURCE", "4"); newChild.SetAttribute("NAME", "lastname"); profile.AppendChild(newChild); doc.Save("D:\\sample.config"); } catch { } return true; }
0 comments
Post a Comment