Append element : Xml Node : XML C# Examples


C# Examples » XML » Xml Node »

 

Append element









    
using  System;
using  System.Xml;

class  MainClass
{
    static  void  Main(string[]  args)
    {
        XmlDocument  doc  =  new  XmlDocument();
        doc.LoadXml("<book  genre='programming'>"  +
            "<title>Programming</title>"  +
            "</book>");

        XmlNode  root  =  doc.DocumentElement;

        XmlElement  newbook  =  doc.CreateElement("price");
        newbook.InnerText="44.95";

        root.AppendChild(newbook);

        doc.Save(Console.Out);
    }
}
    
   
  
   



Output

Programming
44.95


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo XML
» Xml Node