How to delete a selected xml data from an xml file?

Tripati_tutu
Posted by Tripati_tutu under ASP.NET category on | Points: 40 | Views : 2161
Below is the sample code snippet.
protected void DeleteXmlRecord(object sender, EventArgs ee)
{
XmlDocument docXml = new XmlDocument();

docXml.Load(Server.MapPath(@"App_Data\TestXmlFile.xml"));
XmlNode node = docXml.DocumentElement.ChildNodes.Item(selectedIndexValue);
node.ParentNode.RemoveChild(node);
docXml.Save(Server.MapPath(@"App_Data\smallfools.xml"));

//call the load method to load the updated data
loadUsersXmlData();
}

Comments or Responses

Login to post response