Create XmlDocument class. : XmlDocument « XML « VB.Net






Create XmlDocument class.

 


Option Explicit On
Option Strict On

Imports System
Imports System.Xml
Imports System.Xml.Schema

    Class XmlDocumentSample
        Shared reader As XmlReader
        Shared filename As String = "bookdtd.xml"

        Public Shared Sub Main()
            Dim eventHandler As New ValidationEventHandler(AddressOf XmlDocumentSample.ValidationCallback)
            Try
                Dim settings As New XmlReaderSettings()
                settings.DtdProcessing = DtdProcessing.Parse
                settings.ValidationType = ValidationType.DTD
                AddHandler settings.ValidationEventHandler, eventHandler

                reader = XmlReader.Create(filename, settings)
                Dim doc As New XmlDocument()
                doc.Load(reader)

            Finally
                If Not (reader Is Nothing) Then
                    reader.Close()
                End If
            End Try
        End Sub
        Private Shared Sub ValidationCallback(ByVal sender As Object, ByVal args As ValidationEventArgs)
            Console.WriteLine("Validation error loading: {0}", filename)
            Console.WriteLine(args.Message)
        End Sub
    End Class

   
  








Related examples in the same category

1.XmlDocument.CloneNode
2.XmlDocument.CreateAttribute
3.XmlDocument.CreateCDataSection creates an XmlCDataSection containing the specified data.
4.XmlDocument.CreateComment creates an XmlComment 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.