I have an XML fil that looks like this:
Currently, I'm deserializing the code as follows;
(And it goes on for each node...)
So I'm deserializing each node by themselves. However, I'd like to deserialize the entire XML without having to hard code which class name and which node I want to deserialize. How can I accomplish this? Also, the XML might (it might not) have multiple occurances of a similar named node, as seen above.
Code:
<Environment>
<AreaOfInterest>
<Name>ScenarioMap</Name>
<UpperRight>
<GDC>
<Latitude>-179</Latitude>
<Longitude>-179</Longitude>
<ElevationAGL>0</ElevationAGL>
</GDC>
</UpperRight>
<LowerLeft>
<GDC>
<Latitude>180</Latitude>
<Longitude>180</Longitude>
<ElevationAGL>0</ElevationAGL>
</GDC>
</LowerLeft>
</AreaOfInterest>
</Environment>
Code:
XmlNode xmlnode = doc.SelectSingleNode("//Environment");
XmlSerializer ser = new XmlSerializer(typeof(Environment));
XmlNodeReader reader = new XmlNodeReader(xmlnode);
Environment en = (Environment)ser.Deserialize(reader);
So I'm deserializing each node by themselves. However, I'd like to deserialize the entire XML without having to hard code which class name and which node I want to deserialize. How can I accomplish this? Also, the XML might (it might not) have multiple occurances of a similar named node, as seen above.