I have the following xml I'd like to deserialize into a class
<?xml version="1.0" encoding="utf-8" ?>
<root>
<element1>String1</element1>
<element2>String2</element2>
</root>
I am trying to serialize it into the following class:
[XmlRoot("root")]
public class root
{
[XmlElement("element1")]
internal string element1 { get; set; }
[XmlElement("element2")]
internal string element2 { get; set; }
}
When I try deserializing it using the following code, the config object is instantiated, but the strings are null.
using (TextReader reader = new StreamReader(configFile))
{
XmlSerializer serializer = new XmlSerializer(typeof(root));
this.config = (root)serializer.Deserialize(reader);
}
I've tried using xsd.exe to create an xsd, and then create a class based off of that, but there is too much clutter generated by that tool. I think I'm close here. What am I missing?