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

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » XML » XmlSerializer 
25.7.2.DeSerialize from xml file
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
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.