How to delete specific nodes from an XElement?

后端 未结 6 434
时光取名叫无心
时光取名叫无心 2021-01-11 18:49

I have created a XElement with node which has XML as below.

I want to remove all the \"Rule\" nodes if they contain \"conditions\" node.

6条回答
  •  感情败类
    2021-01-11 19:16

    var el = xRelation.XPathSelectElement("/Rules/Rule/Conditions");
    while (el != null)
    {
          el.Remove();
          el = xRelation.XPathSelectElement("/Rules/Rule/Conditions");
    }
    

提交回复
热议问题