I want to parse XML which I have from WebResponse, I make a request and on the response, I get an XML. This is my response :
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:loginResponse xmlns:ns2="http://tasks.ws.com/">
<LoginResult>
<status>1</status>
<uid>a609fd54-e355b373-fc6a-41a6-b178-0baab0ff944d</uid>
<mapServerList>
<SERVER>
<name>OSM Mapnik</name>
<URL>http://tile.openstreetmap.org/%zoom%/%x%/%y%.png</URL>
<waterMarkText>OpenStreetMap contributors</waterMarkText>
<waterMarkURL>http://www.openstreetmap.org/copyright</waterMarkURL>
<maxZoom>16</maxZoom>
</SERVER>
<SERVER>
<name>OpenCycleMap</name>
<URL>http://tile.opencyclemap.org/cycle/%zoom%/%x%/%y%.png</URL>
<maxZoom>16</maxZoom>
</SERVER>
<SERVER>
<name>OpenCycleMap Transport</name>
<URL>http://tile2.opencyclemap.org/transport/%zoom%/%x%/%y%.png</URL>
<maxZoom>16</maxZoom>
</SERVER>
</mapServerList>
</LoginResult>
</ns2:loginResponse>
</S:Body>
</S:Envelope>
I created c# classes :
[XmlType("LoginResult")]
public class LoginResponse
{
public string Uid { get; set; }
public MapServerList mapServerList { get; set; }
}
[XmlType("SERVER")]
public class SERVER
{
string name { get; set; }
string URL { get; set; }
int maxZoom { set; get; }
}
[XmlType("mapServerList")]
public class MapServerList
{
List<SERVER> mapServerList { get; set; }
}
And I tried do this :
XmlSerializer serializer = new XmlSerializer(typeof(LoginResponse));
LoginResponsedeserialized = (LoginResult)serializer.Deserialize(stream);
But it does not work, it always returns null.