我应该如何让<site-standard-profile-request>
子元素正确反序列化,使其不显示为空?
反序列化过程完善;我只需要让子元素<site-standard-profile-request>
也进行序列化。
//<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
//- <person>
// <first-name>Storefront</first-name>
// <last-name>Doors</last-name>
// <headline>CEO at StorefrontDoors.NET</headline>
//- <site-standard-profile-request>
// <url>http://www.linkedin.com/profile?viewProfile=&key=147482099&authToken=-Igm&authType=name&trk=api*a216630*s224617*</url>
// </site-standard-profile-request>
// </person>
[XmlRoot("person")]
[Serializable()]
public class LinkedIn
{
[XmlElement("first-name")]
public string FirstName { get; set; }
[XmlElement("last-name")]
public string LastName { get; set; }
[XmlElement("headline")]
public string Headline { get; set; }
public string URL { get; set; }
}
string profile = oauth.APIWebRequest("GET", "https://api.linkedin.com/v1/people/~", null);
//
LinkedIn lkIn = null;
BufferedStream stream = new BufferedStream(new MemoryStream());
stream.Write(Encoding.ASCII.GetBytes(profile), 0, profile.Length);
stream.Seek(0, SeekOrigin.Begin);
StreamReader sr = new StreamReader(stream);
XmlSerializer serializer = new XmlSerializer(typeof(LinkedIn));
lkIn = (LinkedIn)serializer.Deserialize(sr);
stream.Close();