I have a "xml" file which looks like this:
<root>
<a>
<b>
</b>
</a>
</root>
<root>
<a>
<b>
</b>
</a>
</root>
<root>
<a>
<b>
</b>
</a>
</root>
....
which is created with the serialize method over a list of objects. So i have the matching class to deserialize it.
Now when i try to deserialize i get the error of multiple roots. Is there a way to deserialize this file in to a list of objects again?
One idea of mine would be to wrap another class around the listed classes and call it something like "rootclass" and than serialize only this one. This would than lead to a single root. But is there anotehr way of doing it with only the given XML file?
my deserialization looks like this:
static public List<CT> DeSerialize(string FileName)
{
XmlSerializer deserializer = new XmlSerializer(typeof(List<CT>), new XmlRootAttribute("root"));
List<CT> result;
using (FileStream fileStream = new FileStream(@FileName, FileMode.Open))
{
result = (List<CT>)deserializer.Deserialize(fileStream);
}
return result;
}