本文整理汇总了VB.NET中System.Xml.XmlDocument.XmlDocument构造函数的典型用法代码示例。如果您正苦于以下问题:VB.NET XmlDocument构造函数的具体用法?VB.NET XmlDocument怎么用?VB.NET XmlDocument使用的例子?那么恭喜您, 这里精选的构造函数代码示例或许可以为您提供帮助。您也可以进一步了解该构造函数所在类System.Xml.XmlDocument
的用法示例。
在下文中一共展示了XmlDocument构造函数的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: New
Option Explicit On
Option Strict On
Imports System.Xml
Imports System.Xml.Schema
Namespace Microsoft.Samples.Xml
NotInheritable Class XmlDocumentSample
Private Sub New()
End Sub
Shared reader As XmlReader
Shared filename As String = "bookdtd.xml"
Public Shared Sub Main()
Dim eventHandler As New ValidationEventHandler(AddressOf XmlDocumentSample.ValidationCallback)
Try
' Create the validating reader and specify DTD validation.
Dim settings As New XmlReaderSettings()
settings.DtdProcessing = DtdProcessing.Parse
settings.ValidationType = ValidationType.DTD
AddHandler settings.ValidationEventHandler, eventHandler
reader = XmlReader.Create(filename, settings)
' Pass the validating reader to the XML document.
' Validation fails due to an undefined attribute, but the
' data is still loaded into the document.
Dim doc As New XmlDocument()
doc.Load(reader)
Console.WriteLine(doc.OuterXml)
Finally
If Not (reader Is Nothing) Then
reader.Close()
End If
End Try
End Sub
' Display the validation error.
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
End Namespace