XmlDocument.CreateComment creates an XmlComment containing the specified data. : XmlDocument « XML « VB.Net






XmlDocument.CreateComment creates an XmlComment containing the specified data.

 


Option Explicit
Option Strict

Imports System
Imports System.IO
Imports System.Xml

Public Class Sample

    Public Shared Sub Main()
        Dim doc As New XmlDocument()
        doc.LoadXml("<book genre='Computer' ISBN='1-111111-57-5'>" & _
                    "<title>C#</title>"  & _
                    "</book>")

        Dim newComment As XmlComment
        newComment = doc.CreateComment("Sample XML document")

        Dim root As XmlElement = doc.DocumentElement
        doc.InsertBefore(newComment, root)

        doc.Save(Console.Out)
    End Sub 'Main 
End Class 'Sample

   
  








Related examples in the same category

1.Create XmlDocument class.
2.XmlDocument.CloneNode
3.XmlDocument.CreateAttribute
4.XmlDocument.CreateCDataSection creates an XmlCDataSection containing the specified data.
5.XmlDocument.CreateDocumentFragment creates an XmlDocumentFragment.
6.XmlDocument.CreateDocumentType returns a new XmlDocumentType object.
7.XmlDocument.CreateElement creates an element with the specified name.
8.XmlDocument.CreateElement creates an element with the specified Prefix, LocalName, and NamespaceURI.
9.XmlDocument.CreateEntityReference creates an XmlEntityReference with the specified name.
10.Validates XmlDocument against the XML Schema Definition Language (XSD) schemas
11.Saves all the children of the XmlDocument node to the specified XmlWriter.
12.Saves the XmlDocument node to the specified XmlWriter.
13.Gets the XmlDocument to which this node belongs.
14.Set InnerText to a string that includes markup
15.Set InnerXml to a string that includes markup
16.Create a shallow clone.
17.Gets or sets a value indicating whether to preserve white space in element content.
18.InnerXml includes the markup of the element
19.Gets or sets the tag format of the element.