Click here to Skip to main content
Click here to Skip to main content

Tagged as

Go to top

Delete an XML node using the node name

, 23 Aug 2011
Rate this:
Please Sign up or sign in to vote.
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);

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

b4usat

India India
No Biography provided

Comments and Discussions

 
GeneralReason for my vote of 3 Good, but it will fail if no Element... PinmemberKim Togo30-Aug-11 1:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140905.1 | Last Updated 23 Aug 2011
Article Copyright 2011 by b4usat
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid