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 / C++ / MFC
  4. How to Add Data to a dataset and write to an xml file

How to Add Data to a dataset and write to an xml file

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionxml
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.
  • M Offline
    M Offline
    Mikan23
    wrote on last edited by
    #1

    I have a dataset that I read from an xml file using DataSet.ReadXml(fs); I then add to the dataset and rewrite the xml file using the following: DataRow newrow = mf.quotesDataSet.Tables["quote"].NewRow(); newrow["thequote"] = quoteInput.Text; newrow["speaker"] = speakerInput.Text; newrow["origin"] = originInput.Text; newrow["image"] = "test.jpg"; mf.quotesDataSet.Tables["quote"].Rows.Add(newrow); mf.quotesDataSet.WriteXml(fw); It does add the data, however, it adds it outside the main xml hierarchy. For example, instead of: <rss> <channel> <quote><thequote>text</thequote></quote> <quote><thequote>text</thequote></quote> <quote><thequote>new text</thequote></quote> </channel> </rss> it writes to the file as: <rss> <channel> <quote><thequote>text</thequote></quote> <quote><thequote>text</thequote></quote> </channel> </rss> <quote><thequote>new text</thequote></quote> how do I make the added rows to the dataset write into the proper hierarchy?

    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