Learn .NET from dotNetDave!

Fundamentals of the .NET Framework class will be starting up at UCSD Extensions in San Diego, Ca

Advertisements

Serialize and Deserialize Xml to Disk Using Generics

If you need to serialize and deserialize your objects and persist them to disk, the the code below is an easy way to accomplish this. The GetObjectTypes function correctly detects types so that the serializer will do it's job correctly. Without this you could run into problems (as I did).VB     ''' <summary>     ''' … Continue reading Serialize and Deserialize Xml to Disk Using Generics

Using LINQ to Read Xml Instead of XmlDocument

If you are interested in using LINQ to read Xml instead of the older way of the XmlDocument and SelectNodes, the code below is a pretty good example. The code takes in the ISO standard file for country names and codes (see sample below) and turn it into a list of Country objects for use … Continue reading Using LINQ to Read Xml Instead of XmlDocument

How to Serialize and Deserialize Your Objects

I came up with some generic methods to do the job:Public Shared Function DeserializeXMLToObject(ByVal input As String, ByVal type As System.Type) As Object  Dim result As Object = Nothing  Dim serializer As New XmlSerializer(type)  Try    result = serializer.Deserialize(New XmlTextReader(New StringReader(input)))  Catch ex As Exception    Debug.WriteLine(ex.Message)  End Try   Return resultEnd FunctionPublic Shared Function SerializeObjectToXML(ByVal input As … Continue reading How to Serialize and Deserialize Your Objects

How to Serialize/Deserialize Your Objects

I came up with some generic methods to do the job:Public Shared Function DeserializeXMLToObject(ByVal input As String, ByVal type As System.Type) As Object  Dim result As Object = Nothing  Dim serializer As New XmlSerializer(type)  Try    result = serializer.Deserialize(New XmlTextReader(New StringReader(input)))  Catch ex As Exception    Debug.WriteLine(ex.Message)  End Try   Return resultEnd FunctionPublic Shared Function SerializeObjectToXML(ByVal input As … Continue reading How to Serialize/Deserialize Your Objects