Remove nodes using XDocument

Niladri.Biswas
Posted by Niladri.Biswas under C# category on | Points: 40 | Views : 676
I have a XML file
<rows>
<head>
<beforeInit>
<call command="attachHeader">
<param>#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter</param>
</call>
</beforeInit>
<afterInit>
<call command="enablePaging">
<param>recinfoArea</param>
</call>
</afterInit>
<column width="100" align="center" type="ro" sort="server" color="undefined" id="Id">Id</column>
<column width="100" align="center" type="ro" sort="server" color="undefined" id="NazovProjektu">NazovProjektu</column>
</head>
</rows>


I'd like to remove the beforeInit and afterInit elements.

Solution

xml.Descendants().Where(e=>e.Name == "beforeInit" || e.Name == "afterInit").Remove();

Comments or Responses

Login to post response