Adding an element to the document : Xml Creation : XML C# Examples


C# Examples » XML » Xml Creation »

 

Adding an element to the document









    
using  System;
using  System.Xml;

class  MainClass
{
    static  void  Main(string[]  args)
    {
                XmlDocument  xmlDoc  =  new  XmlDocument();
                xmlDoc.LoadXml("<Record>  Some  Value  </Record>");

                XmlNode  node1  =  xmlDoc.CreateComment("DOM  Testing  Sample");
        xmlDoc.AppendChild(  node1);

        node1  =  xmlDoc.CreateElement("FirstName");
        node1.InnerText  =  "M";
        xmlDoc.DocumentElement.AppendChild(node1);

        xmlDoc.Save(Console.Out);
    }        
}
    
   
  
   



Output

 Some Value M


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo XML
» Xml Creation