0
ID와 같이 피드의 간단한 비트를 바인딩 할 수 있지만 복잡한 객체를 파싱하려고하면 항상 null이됩니다. 매핑에서 내가 뭘 잘못하고 있니?XML을 복잡한 객체에 비 직렬화
피드
[XmlRoot("feed", Namespace = "http://www.w3.org/2005/Atom")]
public class Feed
{
[XmlElement("author")]
Author Author { get; set; }
[XmlElement("entry")]
List<Entry> Entries { get; set; }
[XmlElement("id")]
public string Id { get; set; }
}
저자
[XmlType("author")]
public class Author
{
[XmlElement("name")]
public string Name { get; set; }
[XmlElement("email")]
public string Email { get; set; }
}
항목
[XmlType("entry")]
public class Entry
{
[XmlElement("id")]
public string Id { get; set; }
[XmlElement("published")]
DateTime Published { get; set; }
[XmlElement("updated")]
DateTime Updated { get; set; }
[XmlElement("title")]
public string Title { get; set; }
}
직렬화 복원
using (Stream stream = res.GetResponseStream())
{
XmlSerializer serializer = new XmlSerializer(typeof(Feed));
feed = (Feed)serializer.Deserialize(stream);
}
표시 입력 XML. –
[신디케이션 네임 스페이스] (https://msdn.microsoft.com/en-us/library/system.servicemodel.syndication (v = vs.110) .aspx)를 참조하십시오. RSS를 사용하려면 [SyndicationFeed Class] (https://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed (v = vs.110) .aspx)를 사용하십시오. –
프로젝트가 .net 코어를 사용 중입니다. 입력 된 XML은 과 같은 블로그 피드 atom 피드입니다. http://cellularscale.blogspot.com/feeds/posts/default – Evr