Delete Data from XML File Using C#

07 Jan

Sample XML File

<?xml version="1.0" encoding="utf-8"?>




<name>Ranil Jayaweera</name>





<name>Aruna Gunathilaka</name>





<name>Jaya Palipana</name>




The Code

XmlDocument xmlDoc = new XmlDocument();

xmlDoc.Load(Application.StartupPath + "\\DoctorsList.xml");

XmlNode rootNode = xmlDoc.SelectSingleNode("//DoctorInfo");

XmlNodeList doctorList = rootNode.SelectNodes("Doctor");

for (int i = 0; i < doctorList.Count; i++)


if (doctorList[i].SelectSingleNode("id").InnerText.Equals(“03”))



xmlDoc.Save(Application.StartupPath + "\\DoctorsList.xml");


Leave a comment

Posted by on January 7, 2012 in C#.Net, XML


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: