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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -