You will need something like this
var xml = XElement.Parse(
@"<appSettings><add key=""Prop1"" value=""1"" /><add key=""Prop2"" value=""2"" /></appSettings>");
new ConfigProp
{
Prop1=xml
.Elements("add")
.Single(element=>element.Attribute("key").Value == "Prop1")
.Attribute("value")
.Value,
Prop2 = xml
.Elements("add")
.Single(element => element.Attribute("key").Value == "Prop2")
.Attribute("value")
.Value
};
Note that if your xml does not contain the keys Prop1 and Prop2, this throws an exception.
source
share