Wednesday, 28 December 2011

XML File Operations : Delete from XML file

protected void DeleteXMLNode(string xmlFilePath)
    {
        if (File.Exists(xmlFilePath))
        {
            DataSet ds = new DataSet();
            ds.ReadXml(xmlFilePath);
            string filterExpression = "NAME = '" + TextBox4.Text + "'";
            DataRow[] row = ds.Tables[0].Select(filterExpression);
            if (row.Length == 1)
            {
                row[0].Delete();
                ds.WriteXml(xmlFilePath);
            }
        }
     

No comments:

Post a Comment