I'm not able to deserialize the following secition of an XML with C#
<mainfile>
<portfolio>
<fotos>
<foto> <!CDATA[https://whatever.com/fotos/E/400/photo.JPG]]>
</foto>
</fotos>
</portfolio>
<portfolio>
<fotos>
<foto> <!CDATA[https://whatever.com/fotos/E/400/photo1.JPG]]>
</foto>
</fotos>
</portfolio>
</mainfile>
I think it should be quite straight forward, but when deserializing it always returns an empty list. Here is the code:
[XmlRoot("mainfile")]
public class MainFile
{
public MainFile()
{
porftolios= new List<Portfolio>();
}
[XmlElement("portfolio")]
public List<Portfolio> Portfolios{ get; set; }
}
public class Portfolio
{
....
[XmlElement("fotos")]
public List<Foto> Fotos { get; set; }
}
public class Foto
{
[XmlText]
public string data{ get; set; }
}
Thanks.
EDIT. From HimBromBeere's solution i've chaged the following code, with a successful result:
public class Portfolio
{
....
[XmlArray("fotos")]
[XmlArrayItem("foto")]
public List<Foto> Fotos { get; set; }
}
public class Foto
{
[XmlText]
public string data{ get; set; }
}