Hallo, ich verwende RestSharp in meinem Windows Phone 7.1-Projekt.
Ich habe hier eine Antwort im XML-Format:
https://skydrive.live.com/redir.aspx?cid=0b39f4fbbb0489dd&resid=B39F4FBBB0489DD!139 &parid=B39F4FBBB0489DD!103&authkey=!AOdT-FiS6Mw8v5Y
Ich habe versucht, diese Antwort auf eine Klasse zu deserialisieren:
public class fullWall
{
public _user user { get; set; }
public int numberOfFriend { get; set; }
public int numberOfPhoto { get; set; }
public List<timhotPhotos> timhotPhotos { get; set; }
public fullWall()
{
timhotPhotos = new List<timhotPhotos>();
}
}
Alle Eigenschaften sind in Ordnung, außer der timhotPhotos
-Liste, wie Sie hier sehen können:
timhotPhotos-Klasse:
public class timhotPhotos
{
public string id { get; set; }
public string title { get; set; }
public string description { get; set; }
public string url { get; set; }
public double width { get; set; }
public double height { get; set; }
public DateTime createdDate { get; set; }
public _user user { get; set; }
public int numOfComment { get; set; }
public int numOfRate { get; set; }
public int numOfView { get; set; }
public bool rated { get; set; }
}
Wo liege ich falsch?
Ich habe Ihre Frage in StackOverflow gesehen, dort geantwortet und kopiere jetzt meine Antwort hierher:
Sie müssen den Standard-XML-Deserializer wie folgt in den DotNetXmlDeserializer ändern:
RestClient client;
client.AddHandler("application/xml", new DotNetXmlDeserializer());
Fügen Sie dann das XmlElement-Attribut zur Liste hinzu
public class fullWall
{
public _user user { get; set; }
public int numberOfFriend { get; set; }
public int numberOfPhoto { get; set; }
[System.Xml.Serialization.XmlElement()]
public List<timhotPhotos> timhotPhotos { get; set; }
public fullWall()
{
timhotPhotos = new List<timhotPhotos>();
}
}
Jetzt sollte es gut funktionieren!
Und da Sie die Antwort in StackOverflow akzeptiert haben, mache ich einfach weiter und schließe dieses Problem! ;)
Oh Danke :)
Ps: Ich bin 21 Jahre alt, schön dich kennenzulernen :)
Hilfreichster Kommentar
Oh Danke :)
Ps: Ich bin 21 Jahre alt, schön dich kennenzulernen :)