65.9K
CodeProject is changing. Read more.
Home

Delete an XML node using the node name

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.78/5 (2 votes)

Aug 23, 2011

CPOL
viewsIcon

44629

How to delete an XML node using its name.

Using xml.linq we can delete a node from XML in C#.

XDocument XMLDoc = XDocument.Load(path);
XElement elment = (from xml1 in XMLDoc.Descendants("Node")
                   select xml1).FirstOrDefault();
elment.Remove();
XMLDoc.Save(path);