hi friends
how many ways to update a xml file
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Posted Oct 15, 2007, 5:12 AM
U can use xmlpathdocument and update this is the one way vch u can do
if(!Page.IsPostBack){
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("categories.xml"));
XmlNodeList nodeList = xmlDoc.SelectNodes("/CategoryList/Category[@ID='01']");
// update MainCategory
nodeList[0].ChildNodes[0].InnerText = "ASP.NET";
// update Description
nodeList[0].ChildNodes[1].InnerText = "This is now my ASP.NET list.";
// update Active
nodeList[0].ChildNodes[2].InnerText = "false";
// Don't forget to save the file
xmlDoc.Save(Server.MapPath("categories.xml"));
Response.Write("XML File updated!");
}