本文整理汇总了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
开发者ID:VB.NET开发者,项目名称:System.Xml,代码行数:57,代码来源:XmlDocument
注:本文中的System.Xml.XmlDocument.XmlDocument构造函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论