Hi, Everybody!...
All I need to do is to deserialize the following, seemingly trivial XML...
<ExtendedProperties>
<ExtendedProperty>
<Property>Some Property</Property>
<Value>Some Value</Value>
</ExtendedProperty>
<ExtendedProperty>
<Property>Some Other Property</Property>
<Value>Some Other Value</Value>
</ExtendedProperty>
</ExtendedProperties>
I wrote the following code...
private ExtendedProperties XmlStringToObject(string xmlString)
{
using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(xmlString)))
{
var xmlSerializer = new XmlSerializer(typeof(ExtendedProperties));
return (ExtendedProperties)xmlSerializer.Deserialize(memoryStream);
}
}
- Where ExtendedProperties is simply a List of ExtendedProperty and ExtendedProperty is simply a Property/Value pair.
public class ExtendedProperties : List<ExtendedProperty>
{
***<SNIP />***
}
public class ExtendedProperty
{
public string Property { get; set; }
public string Value { get; set; }
***<SNIP />***
}
I am getting the following error...
System.InvalidOperationException: <ExtendedProperties xmlns=''> was not expected.
What am I doing wrong?