c# - insert new node with its attribute to xml -
i have following xml node
<group> <level id="1" name="level 1" /> <level id="2" name="level 2" /> </group>
how can insert new element it's attributes 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");
Comments
Post a Comment