本文整理汇总了VB.NET中System.Xml.Serialization.XmlElementEventArgs.Element属性的典型用法代码示例。如果您正苦于以下问题:VB.NET XmlElementEventArgs.Element属性的具体用法?VB.NET XmlElementEventArgs.Element怎么用?VB.NET XmlElementEventArgs.Element使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Xml.Serialization.XmlElementEventArgs
的用法示例。
在下文中一共展示了XmlElementEventArgs.Element属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Group
' 导入命名空间
Imports System.IO
Imports System.Xml.Serialization
Imports System.Xml
Imports System.Xml.Schema
Public Class Group
Public GroupName As String
End Class
Public Class Test
Shared Sub Main()
Dim t As Test = new Test()
' Deserialize the file containing unknown elements.
t.DeserializeObject("UnknownElements.xml")
End Sub
Private Sub Serializer_UnknownElement _
(sender As Object , e As XmlElementEventArgs)
Console.WriteLine("Unknown Element")
Console.WriteLine(ControlChars.Tab & e.Element.Name + " " & e.Element.InnerXml)
Console.WriteLine(ControlChars.Tab & e.LineNumber & ":" & e.LineNumber)
Console.WriteLine(ControlChars.Tab & e.LinePosition & ":" & e.LinePosition)
Dim x As Group = CType( e.ObjectBeingDeserialized, Group)
Console.WriteLine (x.GroupName)
Console.WriteLine (sender.ToString())
End Sub
Private Sub DeserializeObject(filename As String)
Dim ser As XmlSerializer = new XmlSerializer(GetType(Group))
' Add a delegate to handle unknown element events.
AddHandler ser.UnknownElement, _
AddressOf Serializer_UnknownElement
' A FileStream is needed to read the XML document.
Dim fs As FileStream = new FileStream(filename, FileMode.Open)
Dim g As Group = CType(ser.Deserialize(fs),Group)
fs.Close()
End Sub
End Class