hi ,
i have created an XML file and needs to update the values of a particular attribute
i tried using xmlwriter class but it writes the whole file again
so please help me out.....if any one knows the solution for it
hi ,
i have created an XML file and needs to update the values of a particular attribute
i tried using xmlwriter class but it writes the whole file again
so please help me out.....if any one knows the solution for it
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
Scott LysleRank #49 · 31K reputationPosted Feb 27, 2008, 5:43 PM EST
Here is a way you can do that:
string path = "c://Scott//Data//sample xml//books.xml"; XmlDocument doc = new XmlDocument(); doc.Load(path); XmlNodeList elems = doc.GetElementsByTagName("title"); for (int i = 0; i < elems.Count; i++) { if (elems[i].InnerXml == "Midnight Rain") { elems[i].InnerXml = "BK Broiler"; } } doc.Save("c://temp/new.xml");Pallavi4 reputationPosted Mar 5, 2008, 7:03 PM EST
it worked