using System.Collections.Generic;
using System.Xml.Serialization;
public static void Main(string[] args)
var documentPropertyMapping =
GetCustomSectionSettingList<CustomSectionConfigElement>("abc/xyz",
"Activity", "value", "Function").ToDictionary(x => x.Key, x => x.Value);
private static List<T> GetCustomSectionSettingList<T>(string sectionName, string elementName, string keyAttributeName,
string valueAttributeName) where T : new()
<Activity value = ""a Document"" Function = ""a Documentation"" />
<Activity value = ""b Document"" Function = ""a Documentation"" />
var settings = new List<T>();
var configDoc = XElement.Parse(xml);
var xOver = new XmlAttributeOverrides();
var attrs = new XmlAttributes();
var root = new XmlRootAttribute(elementName);
xOver.Add(typeof (T), attrs);
var attrs = new XmlAttributes();
attrs.XmlAttribute = new XmlAttributeAttribute(keyAttributeName);
xOver.Add(typeof (T), "Key", attrs);
var attrs = new XmlAttributes();
attrs.XmlAttribute = new XmlAttributeAttribute(valueAttributeName);
xOver.Add(typeof (T), "Value", attrs);
var serializer = new XmlSerializer(typeof (T), xOver);
foreach (var sectionXml in configDoc.XPathSelectElements(sectionName))
foreach (var elem in sectionXml.Elements())
settings.Add((T) serializer.Deserialize(elem.CreateReader()));
public class CustomSectionConfigElement
public string Key { get; set; }
public string Value { get; set; }
#endregion custom section