I have a problem trying to deserialize an xml file created from a different namespace. The code I use is
file = await ApplicationData.Current.LocalFolder.GetFileAsync("EortologioMovingEntries.xml");
try
{
using (IRandomAccessStream stream =
await file.OpenAsync(FileAccessMode.Read))
using (Stream inputStream = stream.AsStreamForRead())
{
DataContractSerializer serializer = new DataContractSerializer(typeof(Anniversaries), "Anniversaries", "http://ift.tt/1ktVebG");
tempAnniversaries = serializer.ReadObject(inputStream) as Anniversaries;
}
}
catch (Exception ex)
{
error = ex.ToString();
tempAnniversaries.Entries.Add(new AnniversaryEntry("Ena", DateTime.Now, "skata", PriorityEnum.High));
}
Eortologio.Model is the namespace that the file was created. I don't get any exceptions but the tempAnniversaries returns null.
this is the start of the xml file.
<ns2:Anniversaries xmlns:ns2="http://ift.tt/1ktVebG" xmlns:xsi="http://ift.tt/ra1lAU">
Any ideas? Thank you.
No comments:
Post a Comment