Fill a list with objects out of a XML file, list stays empty



Hey I have a XML file with a few objects. When i debugg is can see that in my foreach he reads every object, but my "xmlPloegenList" list isn't filled with the objects out of the XML file.



foreach (var item in xmlFile.Descendants("ploeg_info"))
{
if (item.Element("ploeg_info") != null)
{
xmlPloegenList.Add(new PloegElement(new PloegInfo(Convert.ToInt32(item.Element("id").Value),
item.Element("naam").Value, item.Element("volledige_naam").Value, item.Element("logo").Value,
item.Element("opgericht").Value, item.Element("stamnummer").Value, item.Element("kleuren").Value,
item.Element("stadion").Value, item.Element("capaciteit").Value, item.Element("voorzitter").Value,
item.Element("trainer").Value,
new ContactGegevens(item.Element("telefoon").Value, item.Element("fax").Value, item.Element("email").Value,
item.Element("website").Value, item.Element("adres").Value),
new Palmares(item.Element("kampioen").Value, item.Element("beker").Value, item.Element("supercup").Value,
item.Element("gouden_schoen").Value))));

}
}

return xmlPloegenList;


The list is empty after the foreach! Any ideas?


No comments:

Post a Comment