I would suggest instead of trying to parse XML yourself, you try to create classes that would deserialize from the XML into the classes. I would strongly recommend following bendewey’s answer.
But if you cannot do this, there is hope. You can use Convert.ChangeType.
public static T GetValue<T>(String value)
{
return (T)Convert.ChangeType(value, typeof(T));
}
And use like so
GetValue<int>("12"); // = 12
GetValue<DateTime>("12/12/98");