我创建了一个包含下面XML的节点的XElement。
如果"Rule"节点中包含"conditions"节点,我想删除所有这样的节点。
我创建了以下循环,但它没有删除我的节点。
foreach (XElement xx in xRelation.Elements())
{
if (xx.Element("Conditions") != null)
{
xx.Remove();
}
}
示例:
<Rules effectNode="2" attribute="ability" iteration="1">
<Rule cause="Cause1" effect="I">
<Conditions>
<Condition node="1" type="Internal" />
</Conditions>
</Rule>
<Rule cause="cause2" effect="I">
<Conditions>
<Condition node="1" type="External" />
</Conditions>
</Rule>
</Rules>
如果"Rule"节点包含"conditions"节点,我该如何删除所有这样的节点?