C
C#7mo ago
Tobonautilus

Why cannot a nested XML-Element be serialized? What do I miss?

I try to deserialize the YouTube feed. But I cannot get the "group:media" working. It is always null. Do you see any issue with my code? Thanks! Model
[XmlRoot(ElementName = "entry")]
public class Entry
{
[XmlElement(ElementName = "group", Namespace = "media")]
public required Media Media { get; set; }
}

public class Media
{
[XmlElement(ElementName = "title", Namespace = "media")]
public required string Title { get; set; }
}
[XmlRoot(ElementName = "entry")]
public class Entry
{
[XmlElement(ElementName = "group", Namespace = "media")]
public required Media Media { get; set; }
}

public class Media
{
[XmlElement(ElementName = "title", Namespace = "media")]
public required string Title { get; set; }
}
XML
<entry>
<id>yt:video:ZmD1tDVJaAQ</id>
<media:group>
<media:title>I need this property</media:title>
</media:group>
</entry>
<entry>
<id>yt:video:ZmD1tDVJaAQ</id>
<media:group>
<media:title>I need this property</media:title>
</media:group>
</entry>
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server