'这是用XmlSerializer序列化对象的类 Public Class SerializeClass Public Shared Function GetXML(ByVal mObject As Object) As String Dim oSerializer As New System.Xml.Serialization.XmlSerializer(mObject.GetType) Dim oStringWriter As New System.IO.StringWriter oSerializer.Serialize(oStringWriter, mObject) Return oStringWriter.ToString End Function Public Shared Function LoadXML(ByVal mClass As Type, ByVal XML As String) As Object Dim oSerializer As New System.Xml.Serialization.XmlSerializer(mClass) Dim oStringReader As New System.IO.StringReader(XML) Return oSerializer.Deserialize(oStringReader) End Function End Class |