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 -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -