Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I have the following xml node
<group> <level id="1" name="Level 1" /> <level id="2" name="Level 2" /> </group>
How can insert new element with it's attributes to xml file
var doc = XDocument.Load("yourxmlfile.xml"); var x = new XElement("level", new XAttribute("id", 3), new XAttribute("name", "Level 3")); doc.Element("group").Add(x); doc.Save("yourxmlfile.xml");