How to append a xml file?
i have a xml file called my.xml i need to edit the each nodes and attributes and values?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Blocked AccountRank #403 · 6.2K reputationPosted Nov 1, 2008, 12:56 AM EDT
Hi,
By using this code u can edit the xml file here PageNumber is used as the ID of the page.
string FileName = MapPath("/PageTitle.xml");
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(FileName);
XmlNodeList nodeList = xmlDoc.SelectNodes("/PageTitle/Page[@ID=" + PageNumber.ToString() + "]");
nodeList[0].ChildNodes[1].InnerText = ViewState["PageTitle"].ToString();
xmlDoc.Save(FileName);
Happy Coding!!