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. XmlTextWriter 101

XmlTextWriter 101

Scheduled Pinned Locked Moved XML / XSL
csharpc++xmlhelptutorial
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.
  • K Offline
    K Offline
    Kenny ODell
    wrote on last edited by
    #1

    I'm new to the XML world and have been previously using INI type files in old DOS aps and latley in C++ for .NET. Now we're on to the world of C#. I know I can use XmlTextWriter, but the examples don't help too much. Let me set it up for you. The application will have lots of settings that the user can play with. For example, there will be a serial number (text data) and there will be some float data (like a float for the span adjustment of the device). I want to be able to save the contents of a text box to a XML file and read it back. I also will read/write from the target board. So, how you propose I do it? I can see several catagories of items to save, then several items under each catagory. The following C# code doesn't work because it doesn't like the "fi" in the second line: FileInfo fi = new FileInfo(saveFileDialog1.FileName); XmlTextWriter writer = new XmlTextWriter(fi); That's how I would have done in C++ prior to writing to an INI file. Any help will be great, but please be specific. I'm just getting started in XML! Kenny O'Dell Sr. R&D Software Engineer Mettler-Toledo Inc. Inman, SC

    P 1 Reply Last reply
    0
    • K Kenny ODell

      I'm new to the XML world and have been previously using INI type files in old DOS aps and latley in C++ for .NET. Now we're on to the world of C#. I know I can use XmlTextWriter, but the examples don't help too much. Let me set it up for you. The application will have lots of settings that the user can play with. For example, there will be a serial number (text data) and there will be some float data (like a float for the span adjustment of the device). I want to be able to save the contents of a text box to a XML file and read it back. I also will read/write from the target board. So, how you propose I do it? I can see several catagories of items to save, then several items under each catagory. The following C# code doesn't work because it doesn't like the "fi" in the second line: FileInfo fi = new FileInfo(saveFileDialog1.FileName); XmlTextWriter writer = new XmlTextWriter(fi); That's how I would have done in C++ prior to writing to an INI file. Any help will be great, but please be specific. I'm just getting started in XML! Kenny O'Dell Sr. R&D Software Engineer Mettler-Toledo Inc. Inman, SC

      P Offline
      P Offline
      Phil Hobgen
      wrote on last edited by
      #2

      Hi, There isn't an XmlTextWriter constructor that takes a FileInfo as a parameter. There's a choice of three constructors, it looks like you probably want to use this one: public XmlTextWriter(string filename, Encoding encoding); Cheers Phil Hobgen barbari.co.uk Southampton, UK

      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