C#を使用して次のXMLを逆シリアル化する正しい方法は何ですか?アンラップされたコレクションでXMLをデシリアライズするのに問題があります
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gCal='http://schemas.google.com/gCal/2005'>
<id>http://www.google.com/cal...</id>
<subtitle type='text'>RockPointe Events (1)</subtitle>
<entry>
<id>http://www.google.com/cal...</id>
<published>2011-07-07T21:43:44.000Z</published>
<updated>2011-07-07T21:48:31.000Z</updated>
<title type='html'>Event 1</title>
<summary type='html'>Event 1 Summary</summary>
<content type='html'>Event 1 Content</content>
</entry>
<entry>
<id>http://www.google.com/cal...</id>
<published>2011-07-07T21:43:44.000Z</published>
<updated>2011-07-07T21:48:31.000Z</updated>
<title type='html'>Event 2</title>
<summary type='html'>Event 2 Summary</summary>
<content type='html'>Event 2 Content</content>
</entry>
</feed>
ここに私の現在のPOCO
[XmlRoot(ElementName = "feed", Namespace = "http://www.w3.org/2005/Atom")]
public class Feed
{
[XmlElement("subtitle")]
public string Subtitle { get; set; }
[XmlElement("title")]
public string Title { get; set; }
[XmlElement("entry")]
public m_Entry[] Entry { get; set; }
[XmlType(Namespace = "")]
public class m_Entry
{
[XmlElement("title")]
public string Title { get; set; }
[XmlElement("summary")]
public string Summary { get; set; }
[XmlElement("content")]
public string Content { get; set; }
[XmlElement("published")]
public DateTime Published { get; set; }
[XmlElement("updated")]
public DateTime Updated { get; set; }
}
}
私は私のDeserialize
メソッドを介してそれを実行すると、予想通り、私はTitle
とSubtitle
を取得します。です問題はentry
です。 2つのエントリが表示されますが、すべてがnullです。私は気づく
から
XmlType
属性を削除するのと同じくらい簡単だっ表示されます私は、あなたが言ってみました'null'エントリプロパティの配列(これは私が上にあるもの)の代わりに、あなたは' entry'オブジェクトを 'null'として返します –