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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. creat a xml with data appending on the other

creat a xml with data appending on the other

Scheduled Pinned Locked Moved C#
xmldatabasehelptutorial
1 Posts 1 Posters 2 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
    dhol
    wrote on last edited by
    #1

    Hi I have did a program such that , i will have two text box name and age in my form..and a button named save. so that when the values entered r in the text box..a xml file is created with those data.. . Now I can able to create one set of values…. Now what I need is that when again some other value is entered in the textbox. It should also be written in the xml file..but without deleting the other. I mean it should append on the other.. For example: first I entered first as john and 22 for name and age ..it will added in the xml file..now again if I enter charu and 23 as name and age.. Now xml should have john and 22 as well as charu and 23… And also one more thing is that if I again enter John. It should give a message that it has already been entered. No values should be repeated again. Please help me to do this….. The coding which I did is as follows. In side the button click //save Button private void button1_Click(object sender, System.EventArgs e) { DataSet dataSet = new DataSet(); //read the schema dataSet.ReadXmlSchema("..\\..\\PlaygroMenu.xsd"); //create a new row DataRow oValues; oValues = dataSet.Tables[0].NewRow(); //enter the values oValues[0] = txtName.Text; oValues[1] = Convert.ToInt32(txtAage.Text); //check for duplication bool hasalready = false; foreach(DataRow row in dataSet.Tables[0].Rows) { if(row.ItemArray[0].ToString().Equals(txtID.Text)) { hasalready = true; } } // if(!hasalready) { //add the row to the dataset dataSet.Tables[0].Rows.Add(oValues); //write the data to a xml file dataSet.WriteXml("..\\..\\resultdata.xml", XmlWriteMode.WriteSchema); MessageBox.Show("Saved"); } else { MessageBox.Show("Already Exists"); } } private void Form1_Load(object sender, System.EventArgs e) { DataSet dataSet = new DataSet(); //read the schema dataSet.ReadXmlSchema("..\\..\\Menu.xsd"); System.IO.FileInfo file = new System.IO.FileInfo("..\\..\\mydata.xml"); //check whethere there is result xml file... if (file.Exists) { dataSet.ReadXml("..\\..\\resultdata.xml"); } } Please help me to do this.. Dhol

    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