本文整理汇总了VB.NET中System.Xml.Serialization.XmlAnyElementAttribute类的典型用法代码示例。如果您正苦于以下问题:VB.NET XmlAnyElementAttribute类的具体用法?VB.NET XmlAnyElementAttribute怎么用?VB.NET XmlAnyElementAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XmlAnyElementAttribute类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: XClass
Public Class XClass
' Apply the XmlAnyElementAttribute to a field returning an array
' of XmlElement objects.
<XmlAnyElement()> Public AllElements() As XmlElement
End Class
Public Class Test
Public Shared Sub Main()
Dim t As New Test()
t.DeserializeObject("XFile.xml")
End Sub
Private Sub DeserializeObject(filename As String)
' Create an XmlSerializer.
Dim mySerializer As New XmlSerializer(GetType(XClass))
' To read a file, a FileStream is needed.
Dim fs As New FileStream(filename, FileMode.Open)
' Deserialize the class.
Dim x As XClass = CType(mySerializer.Deserialize(fs), XClass)
' Read the element names and values.
Dim xel As XmlElement
For Each xel In x.AllElements
Console.WriteLine((xel.LocalName & ": " & xel.Value))
Next xel
End Sub
End Class