how to remove Xelement without its children node using LINQ?

后端 未结 4 975
伪装坚强ぢ
伪装坚强ぢ 2021-01-14 02:49

Here is my XML,


    
      
           
    
    
         


        
4条回答
  •  太阳男子
    2021-01-14 03:25

    If node name is deprecated and must not be used in the whole document, just use ReplaceWith:

    var xNode = doc.Descendants("x");
    for (int i = 0; i < xNode.Count; i++)
    {
        xNode[i].ReplaceWith(xNode[i].Nodes());
    }
    

提交回复
热议问题