By using LINQ to XML it is easy to achieve what you need.
I saved your XML as a file on the file system.
<?xml version="1.0"?>
<SecurityAttributeCustomMetadata>
<attribute displayName="Security : projectname">
<add collectionTypeName="BasicExperiment" sectionTypeName="Title"
fieldName="Metadata" propertyName="ProjectName"/>
</attribute>
<attribute displayName="Security : projectNumber">
<add collectionTypeName="BasicExperiment" sectionTypeName="Title"
fieldName="Metadata" propertyName="ProjectNumber"/>
</attribute>
<!-- Fields from two section type can be combined together and configure as a single security attribute in the SNB -->
<attribute displayName="Security : customName">
<add collectionTypeName="BasicExperiment" sectionTypeName="Title"
fieldName="Metadata" propertyName="userName"/>
<add collectionTypeName="MyExperimentType"
sectionTypeName="MySectionType" fieldName="MyFieldName"
propertyName="MyPropertyName"/>
</attribute>
</SecurityAttributeCustomMetadata>
c#
void Main()
{
XDocument xdoc = XDocument.Load(@"e:\Temp\CustomConfigSection.xml");
foreach (XElement xelem in xdoc.Descendants("add"))
{
Console.WriteLine("collectionTypeName: '{0}', sectionTypeName: '{1}'"
, xelem.Attribute("collectionTypeName").Value
, xelem.Attribute("sectionTypeName").Value
);
}
}
Output
collectionTypeName: 'BasicExperiment', sectionTypeName: 'Title'
collectionTypeName: 'BasicExperiment', sectionTypeName: 'Title'
collectionTypeName: 'BasicExperiment', sectionTypeName: 'Title'
collectionTypeName: 'MyExperimentType', sectionTypeName: 'MySectionType'