0
は、私はそれらのコンテキストのレコードをピックアップする必要がある場所私はXMLファイルの属性値をフィルタリングする方法は?
public class ContextElements
{
public string Property { get; set; }
public string Value { get; set; }
}
は今、新たな要件が来た
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 }));
をやっている現在では、以下のxmlファイル
<?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>
に考えてみましょうその属性値はenabled = "1"です。
どうすればいいですか?
ヘルプが必要です。
おかげで多くのことを –