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. My XmlFile looses its tree hierarchy after saving it

My XmlFile looses its tree hierarchy after saving it

Scheduled Pinned Locked Moved C#
databasedata-structuresxmlhelptutorial
1 Posts 1 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.
  • R Offline
    R Offline
    rudy net
    wrote on last edited by
    #1

    I have been working with xml files for a while; however, now I have to work with a xml file that has several relations that are not hierarchical which makes it a bit harder to manipulate with XmlDocument so I figured I could use datasets because a dataset automatically creates all the necessary tables. So to test it out I assign a table to the datasource of a datagrid. My problem is that when new rows are added to the datagrid, and I call my dataset's WriteXml method, the new rows are added at the root level and my file looses its original tree hierarchy. For example, if my original xml file is as follows: Then I set the DataSource to of a datagrid to "Position" table and after adding a couple of rows, the saved file looks like: Note that the new rows were added in "/root" instead of in "root/Database/positions" Please let me know if there is a way to preserve the xml tree hierarchy when using datasets. Many thanks in advance.

    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