Create a detailed guide on how to perform create, read, update, delete operations on XML file in ASP.NET Web Form.
Compare and contrast disconnected architecture vs connected architectu
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Cynthia SathuragiriRank #937 · 2.2K reputationPosted Mar 24, 2026, 12:24 AM EDT
In ASP.NET Web Forms, you can perform CRUD operations on an XML file using the
XmlDocumentclass.1. Create (Insert)
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("~/App_Data/products.xml"));
XmlElement product = doc.CreateElement("Product");
product.SetAttribute("id", "2");
XmlElement name = doc.CreateElement("Name");
name.InnerText = "Mobile";
product.AppendChild(name);
doc.DocumentElement.AppendChild(product);
doc.Save(Server.MapPath("~/App_Data/products.xml"));
```
2. Read
XmlNodeList list = doc.SelectNodes("/Products/Product");
foreach (XmlNode node in list)
{
string name = node["Name"].InnerText;
}
```
3. Update
XmlNode node = doc.SelectSingleNode("/Products/Product[@id='1']");
node["Name"].InnerText = "Updated Name";
doc.Save(path);
```
4. Delete
XmlNode node = doc.SelectSingleNode("/Products/Product[@id='1']");
node.ParentNode.RemoveChild(node);
doc.Save(path);
```
Use XPath to locate nodes and always save changes using
doc.Save(). XML is suitable for small data storage; for larger apps, prefer a database.