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. XML / XSL
  4. create xml file using streamwriter

create xml file using streamwriter

Scheduled Pinned Locked Moved XML / XSL
xmlhelp
4 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.
  • J Offline
    J Offline
    jphuphilly
    wrote on last edited by
    #1

    Hi im trying to use this line of code to create an xml file but it just overwrites it every time or appends to the wrong part. I have tried changing the bool to true and false also tried changing write to writeline nothing works please help. using (StreamWriter sw = new StreamWriter("TestFile.xml")) { sw.Write("" + " " + DispID.Text + "" + " " + listBox2.SelectedItem.ToString() + "" + " " +listBox3.SelectedItem.ToString()+ "" + "" ); } Thanks alot, :-D:-D:-D Da Intern

    A 1 Reply Last reply
    0
    • J jphuphilly

      Hi im trying to use this line of code to create an xml file but it just overwrites it every time or appends to the wrong part. I have tried changing the bool to true and false also tried changing write to writeline nothing works please help. using (StreamWriter sw = new StreamWriter("TestFile.xml")) { sw.Write("" + " " + DispID.Text + "" + " " + listBox2.SelectedItem.ToString() + "" + " " +listBox3.SelectedItem.ToString()+ "" + "" ); } Thanks alot, :-D:-D:-D Da Intern

      A Offline
      A Offline
      adaoja
      wrote on last edited by
      #2

      Hi Isn´t XmlTextWriter a better choice? in VB Dim wrtXMLWriter As New XmlTextWriter("TestFile.xml", Nothing) and use .WriteRaw or any other XmlTextWriter-method that works for your purposes. Regards Daniel

      J 1 Reply Last reply
      0
      • A adaoja

        Hi Isn´t XmlTextWriter a better choice? in VB Dim wrtXMLWriter As New XmlTextWriter("TestFile.xml", Nothing) and use .WriteRaw or any other XmlTextWriter-method that works for your purposes. Regards Daniel

        J Offline
        J Offline
        jphuphilly
        wrote on last edited by
        #3

        okay but i want it to create a new set of elements like this: when i click this button it creates the xml file and the first element then when i click it again it adds the new elements to that xml file. Da Intern

        A 1 Reply Last reply
        0
        • J jphuphilly

          okay but i want it to create a new set of elements like this: when i click this button it creates the xml file and the first element then when i click it again it adds the new elements to that xml file. Da Intern

          A Offline
          A Offline
          adaoja
          wrote on last edited by
          #4

          You can use XmlDocument.CreateElement and .AppendChild to add your information to your document. in c++ given that Child,Name,TopElement all are XmlElements sData is the content, the info in the element; ChildElement = doc->CreateElement("tagname"); TopElement->AppendChild(ChildElement); NameElement = doc->CreateElement("tagname"); NameElement->InnerText = sData; ChildElement->AppendChild(NameElement); .. or something like that I guess you have to check in the button_click function if you already have pressed the button and if not -> create a new xmldokument Regards:) Daniel

          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