DeSerialize from xml file : XmlSerializer « XML « VB.Net Tutorial






Imports System.Xml.Serialization, System.IO

Public Class Tester
    Public Shared Sub Main
    
      Dim theSerializer As New XmlSerializer(GetType(employee))
      Dim sw As New StreamReader("data.xml")
      Dim theWorker As employee
      theWorker = theSerializer.Deserialize(sw)
      Console.WriteLine(theWorker.first_name )
      Console.WriteLine(theWorker.last_name )
      Console.WriteLine(theWorker.title)


    End Sub

End Class

Public Class employee
   Public first_name As String
   Public last_name As String
   Public title As String

   Public Sub New()
   End Sub

   Public Sub New(ByVal first_name As String,ByVal last_name As String,ByVal title As String)
      Me.first_name = first_name
      Me.last_name = last_name
      Me.title = title
   End Sub

End Class








25.7.XmlSerializer
25.7.1.Serialize Class to xml file
25.7.2.DeSerialize from xml file
25.7.3.XML Serialization