Change this foreach loop:
foreach (var p in setting)
{
settingsList.Add(p.Element("Setting").Element("Name").Value);
settingsList.Add(p.Element("Setting").Element("Visible").Value);
}
To:
foreach (var p in setting.Elements("Setting"))
{
settingsList.Add(p.Element("Name").Value);
settingsList.Add(p.Element("Visible").Value);
}
There is only one Settings
element under each Client
.So your loop running for one time and you are getting the first item using p.Element("Setting")
, instead you should iterate over the child elements of Settings
.Also, instead of List<string>
you may want to consider using a Dictionary
.