Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Updating records in XML

Updating records in XML

Scheduled Pinned Locked Moved C#
questionannouncementcsharpdesignxml
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Latheesan
    wrote on last edited by
    #1

    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.

    C 1 Reply Last reply
    0
    • L Latheesan

      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.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups