考虑下面的 xml 文件
<?xml version="1.0" encoding="utf-8"?>
<RootElement>
<HomeSite>
<Context enabled="1" active="1">
<Culture>en-us</Culture>
<Affiliate>0</Affiliate>
<EmailAddress>sreetest@test.com</EmailAddress>
<Password>sreesree1</Password>
</Context>
<Context enabled="0" active="1">
<Culture>en-us</Culture>
<Affiliate>0</Affiliate>
<EmailAddress>sreetest@test.com</EmailAddress>
<Password>sreesree1</Password>
</Context>
</HomeSite>
</RootElement>
目前我在做
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 }));
在哪里
public class ContextElements
{
public string Property { get; set; }
public string Value { get; set; }
}
现在出现了一个新要求,我需要为那些属性值启用=“1”的上下文提取记录。
那么该怎么做呢?
需要帮助。