I get a file with different content (currently 4 different classes), either
<ClassA><!-- content --></ClassA>
or
<ClassB><!-- content --></ClassB>
or ...
At time of parsing I have no further information which class is in the file.
So, currently, I try to parse by trial and error:
try
{
ClassA result = (ClassA)new XmlSerializer(typeof(ClassA)).Deserialize(reader);
if(!(result is null)) { \\do something }
}
catch (Exception) {}
And the same for ClassB
and so on ...
Is there a more elegant way to parse the classes?
I can give all classes the same base class, although the are quite different in their form.