XmlDocument.CreateComment(String comments) : XmlDocument « System.Xml « C# / C Sharp by API






XmlDocument.CreateComment(String comments)

  

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

   
    
  








Related examples in the same category

1.new XmlDocument()
2.XmlDocument.AppendChild(XmlNode docNode)
3.XmlDocument.CreateElement
4.XmlDocument.CreateXmlDeclaration
5.XmlDocument.LoadXml(String xmlString)
6.XmlDocument.Save()
7.XmlDocument.SelectNodes
8.XmlDocument.SelectSingleNode