Is it possible to deserialize DataTable to custom Class? One of soap requests return DataTable in this format
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="geolocation" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="geolocation">
<xs:complexType>
<xs:sequence>
<xs:element name="Latitude" type="xs:float" minOccurs="0"/>
<xs:element name="Longitude" type="xs:float" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<geolocation diffgr:id="geolocation" msdata:rowOrder="0">
<Latitude>48.8186</Latitude>
<Longitude>28.4681</Longitude>
</geolocation>
...
</NewDataSet>
</diffgr:diffgram>
I would like to deserialize it into an array of
public class Geolocation {
public double latitude { get; set; }
public double longitude { get; set; }
}
using XmlSerializer
XmlSerializer serializer = new XmlSerializer(typeof(Geolocation[]))
var Geolocations = (Geolocation)serializer.Deserialize(stream);
Edit: I tried to do something like this:
public class Geolocation {
[XmlElement("Latitude")]
public double Latitude { get; set; }
[XmlElement("Longitude")]
public double Longitude { get; set; }
}
but this didnt work