Mega Code Archive

 
Categories / C# Tutorial / XML
 

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);   } } Programming 44.95