У меня есть XDocument, что я хочу, чтобы удалить весь узел Allocation, когда значение узла Account = TESTXElement удалить родительский узел
<Order>
<Quantity>800</Quantity>
<Allocations>
<Allocation>
<Account>ACCT1</Account>
<Quantity>100</Quantity>
</Allocation>
<Allocation>
<Account>TEST</Account>
<Quantity>300</Quantity>
</Allocation>
<Allocation>
<Account>ACCT4</Account>
<Quantity>400</Quantity>
</Allocation>
</<Allocations>
</Order>
And my code:
XElement root = XElement.Parse(util.DocAsString(xmlDoc));
IEnumerable<string> acctList = from acct in root.Descendants("Account")
select (string)acct;
foreach (var acct in acctList)
{
root.Elements("Allocation").Where(aa => aa.Element("Account").Value == "TEST").Remove();
}
Однако это не вынимая узел. Пожалуйста, помогите, спасибо.