Consider the below xml file
<?xml version="1.0" encoding="utf-8"?>
<RootElement>
<HomeSite>
<Context enabled="1" active="1">
<Culture>en-us</Culture>
<Affiliate>0</Affiliate>
<EmailAddress>[email protected]</EmailAddress>
<Password>sreesree1</Password>
</Context>
<Context enabled="0" active="1">
<Culture>en-us</Culture>
<Affiliate>0</Affiliate>
<EmailAddress>[email protected]</EmailAddress>
<Password>sreesree1</Password>
</Context>
</HomeSite>
</RootElement>
At present I am doing
string applicationType="HomeSite";
XDocument xmlSkuDescDoc = null;
xmlSkuDescDoc = XDocument.Load(@"D:\Config.xml");
var newContextElementCollection = new List<ContextElements>();
//get the property and values
(from data in xmlSkuDescDoc.Descendants(applicationType)
select data)
.Descendants("Context")
.Elements()
.ToList()
.ForEach(i => newContextElementCollection.Add(new ContextElements { Property = i.Name.ToString(), Value = i.Value }));
Where
public class ContextElements
{
public string Property { get; set; }
public string Value { get; set; }
}
Now a new requirement has come where I need to pick up records for those context whose attribute value is enabled="1".
So how to do so?
Help needed.