2
我正在尝试一天来完成这项工作。我想更新使用LINQ在我的XML货币属性的XML使用LINQ to XML更新子树中的XML属性
我的XML看起来是这样的:
<Bank>
<Customer id="0">
<FName>Adam</FName>
<LName>Kruz</LName>
<Accounts>
<Account id="0" money="1500" />
<Account id="1" money="6500" />
<Account id="2" money="0" />
</Accounts>
</Customer>
<Customer id="1">
<FName>Benny</FName>
<LName>Thoman</LName>
<Accounts>
<Account id="0" money="3200" />
</Accounts>
</Customer>
</Bank>
从来就BEEM这个代码,但没有成功
XDocument document = XDocument.Load("database.xml");
XElement root = document.Root;
root.Elements("Customer")
.Where(e => e.Attribute("id").Value.Equals(customerID.ToString())).Select(e => e.Descendants("Account")
.Where(f => f.Attribute("id").Value.Equals(this.id.ToString())).Select(f => f.Attribute("id")).First().SetValue(money.ToString()));
document.Save("database.xml");
尝试我收到一个错误: 方法'System.Linq.Enumerable.Select(System.Collections.Generic.IEnumerable,System.Func)'的类型参数不能从用法中推断出来。尝试明确指定类型参数。
请告诉我,我怎么在一个元素(账户)感谢的子树(帐户)编辑属性很多:(
这一项工作完美的感谢! – Safiron