Updating records in XML
-
Hello, I'm working on a bank program for my C# course at the Uni. I have this "Save" button on my bank UI which saves everything on the form to a XML file called "Account_Data.xml" My question is, how do you update records in the xml file, if there is an record in there already with the name Account ID. This is the xml file format: < ? xml version = " 1.0 " ? > < Accounts > < Account ID = " 123456 " > < FirstName > Latheesan < / FirstName > < SecondName > Kanes < / SecondName > < Balance > 0 < / Balance > < OverDraftLimit > 50 < / OverDraftLimit > < FullAddress > My Address Here < / FullAddress > < / Account > < / Accounts > Im very new to C# with XML, so im still getting used to this. I'd appreciate it if someone could point me in the right direction.
-
Hello, I'm working on a bank program for my C# course at the Uni. I have this "Save" button on my bank UI which saves everything on the form to a XML file called "Account_Data.xml" My question is, how do you update records in the xml file, if there is an record in there already with the name Account ID. This is the xml file format: < ? xml version = " 1.0 " ? > < Accounts > < Account ID = " 123456 " > < FirstName > Latheesan < / FirstName > < SecondName > Kanes < / SecondName > < Balance > 0 < / Balance > < OverDraftLimit > 50 < / OverDraftLimit > < FullAddress > My Address Here < / FullAddress > < / Account > < / Accounts > Im very new to C# with XML, so im still getting used to this. I'd appreciate it if someone could point me in the right direction.
Hi. The XmlDocument class allows you to search and modify Xml nodes using the Document Object Model ( DOM ), which is a standard interface for working with XML. The language used to search XML is called XPath. The w3schools site is the best IMO for learning about any standard stuff like this, http://www.w3schools.com/xpath/[^] is the starting point for XPath. Basically you use SelectSingleNode or SelectNodes to find the node you want, then you can modify it, remove it, or insert a node just after it. msdn.microsoft.com is the best place for info on the XmlDocument class.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )