Hi,
You need to look into Using Generics in the .NET Framework. Generics allow you pass different types to a Routine and then deal with them as per the Type that was passed. As a quick Example, I use two regular Extension Methods in my regular coding to Serialize and Deserialize different object types into a JSON Structure. i.e:-
vb.net Code:
<Extension()>
Public Function SerializeToJSON(Of T)(ByVal dataToSerialize As T) As String
Dim jsonTool As New JavaScriptSerializer
Return jsonTool.Serialize(dataToSerialize)
End Function
<Extension()>
Public Function DeserializeFromJSON(Of T)(ByVal dataToDeserialize As String, ByVal typeToDeserializeTo As T) As T
Dim jsonTool As New JavaScriptSerializer
Return jsonTool.Deserialize(Of T)(dataToDeserialize)
End Function
Even though this is Not XML this does demonstrate the principle of Serializing and Deserializing any object type using Generics.
I will now leave this to you to get working with XML rather than JSON.
Hope that helps.
Cheers,
Ian