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. How to access fields and values from an XML Database

How to access fields and values from an XML Database

Scheduled Pinned Locked Moved C#
csharpdatabasewinformsxmlhelp
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.
  • D Offline
    D Offline
    DTWC_Lawrence
    wrote on last edited by
    #1

    I have an XML Database that I am loading into a Dataset object in a C# 2008 Windows Forms project. I need to know how to access the individual fields and values. The actual database is not in my control, so I have to use it as given. And I need to be able to offer portions of the values for editing, while hiding others. So I need to how to access each individual field and value. Here is a very tiny mocked up version of the XML code: <?xml version="1.0"?> <database version="1.0"> <DatabaseItem name="FirstTable"> <DatabaseSubitem id="1"> <DatabaseField name="Id" value="1" /> <DatabaseField name="Freq" value="151955000" /> <DatabaseField name="Mode" value="Mode:Selective" /> </DatabaseSubitem> <DatabaseSubitem id="2"> <DatabaseField name="Id" value="1" /> <DatabaseField name="Freq" value="151955000" /> <DatabaseField name="Mode" value="Mode:Selective" /> </DatabaseSubitem> <DatabaseSubitem id="3"> <DatabaseField name="Id" value="65535" /> </DatabaseSubitem> </DatabaseItem> <DatabaseItem name="SecondTable"> <DatabaseSubitem id="0"> <DatabaseField name="access_p" value="500" /> </DatabaseSubitem> </DatabaseItem> <DatabaseItem name="ThirdTable"> <DatabaseSubitem id="0"> <DatabaseField name="access_Short" value="500" /> </DatabaseSubitem> </DatabaseItem> </database> If there is an easier way than the Dataset object to process the database, please let me know. Any help would be most appreciated. Thanks, Bruce

    P 1 Reply Last reply
    0
    • D DTWC_Lawrence

      I have an XML Database that I am loading into a Dataset object in a C# 2008 Windows Forms project. I need to know how to access the individual fields and values. The actual database is not in my control, so I have to use it as given. And I need to be able to offer portions of the values for editing, while hiding others. So I need to how to access each individual field and value. Here is a very tiny mocked up version of the XML code: <?xml version="1.0"?> <database version="1.0"> <DatabaseItem name="FirstTable"> <DatabaseSubitem id="1"> <DatabaseField name="Id" value="1" /> <DatabaseField name="Freq" value="151955000" /> <DatabaseField name="Mode" value="Mode:Selective" /> </DatabaseSubitem> <DatabaseSubitem id="2"> <DatabaseField name="Id" value="1" /> <DatabaseField name="Freq" value="151955000" /> <DatabaseField name="Mode" value="Mode:Selective" /> </DatabaseSubitem> <DatabaseSubitem id="3"> <DatabaseField name="Id" value="65535" /> </DatabaseSubitem> </DatabaseItem> <DatabaseItem name="SecondTable"> <DatabaseSubitem id="0"> <DatabaseField name="access_p" value="500" /> </DatabaseSubitem> </DatabaseItem> <DatabaseItem name="ThirdTable"> <DatabaseSubitem id="0"> <DatabaseField name="access_Short" value="500" /> </DatabaseSubitem> </DatabaseItem> </database> If there is an easier way than the Dataset object to process the database, please let me know. Any help would be most appreciated. Thanks, Bruce

      P Offline
      P Offline
      puri keemti
      wrote on last edited by
      #2

      It will create table under dataset having three rows (1) Id (2) Freq (3) Mode You can access values easily by using

      ds.Tables[0].Rows[0][0] // It will return 1
      ds.Tables[0].Rows[0][1] // 151955000

      so on......

      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