For the reduced XML File:-
<ExtendedAttributes>
<EnableDisplayName>True</EnableDisplayName>
<EditorType>Enhanced</EditorType>
<EnableConversationNotifications>True</EnableConversationNotifications>
<EnableUserSignatures>True</EnableUserSignatures>
<CPPageSize>10</CPPageSize>
<EnableActivityMessageNewUserAvatar>True</EnableActivityMessageNewUserAvatar>
<EnableActivityMessageThirdPartyMessageType>True</EnableActivityMessageThirdPartyMessageType>
<EnableStartConversations>1</EnableStartConversations>
<avatarUrl>~/cfs-file.ashx/__key/communityserver-components-selectableavatars/03b2c875-fbfb-4d26-8000-ef001b9f4728/avatar.png</avatarUrl>
<EnableActivityMessageNewProfileComment>False</EnableActivityMessageNewProfileComment>
<EnableActivityMessageStatus>True</EnableActivityMessageStatus>
</ExtendedAttributes>
You can parse it with:-
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
[XmlRoot("ExtendedAttributes")]
public class SerialisableDictionary : Dictionary<string, string>, IXmlSerializable
{
#region IXmlSerializable Members
public System.Xml.Schema.XmlSchema GetSchema()
{
return null;
}
public void ReadXml(System.Xml.XmlReader reader)
{
reader.Read();
while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
{
string key = reader.Name;
this.Add(key, reader.ReadElementContentAsString());
reader.MoveToElement();
}
reader.ReadEndElement();
}
public void WriteXml(System.Xml.XmlWriter writer)
{
// TODO
}
#endregion
}
class Program
{
static void Main(string[] args)
{
SerialisableDictionary sd = new SerialisableDictionary();
XmlSerializer x = new XmlSerializer(sd.GetType());
using (StreamReader sr = new StreamReader(@"XMLFile1.xml"))
{
sd = (SerialisableDictionary)x.Deserialize(sr);
}
foreach(var kvp in sd)
{
Console.WriteLine(kvp.Key + " = " + kvp.Value);
}
Console.WriteLine("Done.");
Console.ReadKey();
}
}
This gives you a Dictionary<string, string>
you almost certainly want the true/false/string/number values parsed, but that's another problem.
I appreciate this isn't perfect, but it should be enough to get you going. Unfortunately it will get quite involved and I don't have much time.
All based heavily on the answer in Serialize Class containing Dictionary member