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. problem with saving XML to xml file

problem with saving XML to xml file

Scheduled Pinned Locked Moved C#
questionxmlhelp
3 Posts 3 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.
  • W Offline
    W Offline
    Wizard_01
    wrote on last edited by
    #1

    When program enters public method MyClass.Flush 'document' has 5 childnodes. After program opens file.xml variable document has 0 childs - what is wrong :eek: ???

    private static XmlDocument document;
    ....
    /* load data from file*/
    public void Flush() {
    XmlTextWriter writer = new XmlTextWriter("file.xml",System.Text.Encoding.UTF8);
    writer.Formatting = Formatting.Indented;
    document.WriteTo( writer );
    writer.Flush();
    writer.Close();
    }

    Thank you.

    P R 2 Replies Last reply
    0
    • W Wizard_01

      When program enters public method MyClass.Flush 'document' has 5 childnodes. After program opens file.xml variable document has 0 childs - what is wrong :eek: ???

      private static XmlDocument document;
      ....
      /* load data from file*/
      public void Flush() {
      XmlTextWriter writer = new XmlTextWriter("file.xml",System.Text.Encoding.UTF8);
      writer.Formatting = Formatting.Indented;
      document.WriteTo( writer );
      writer.Flush();
      writer.Close();
      }

      Thank you.

      P Offline
      P Offline
      Paresh Gheewala
      wrote on last edited by
      #2

      check the previous System.Text.Encoding.UTF8 encoding format. have u checked preservewhitespace ? Paresh

      1 Reply Last reply
      0
      • W Wizard_01

        When program enters public method MyClass.Flush 'document' has 5 childnodes. After program opens file.xml variable document has 0 childs - what is wrong :eek: ???

        private static XmlDocument document;
        ....
        /* load data from file*/
        public void Flush() {
        XmlTextWriter writer = new XmlTextWriter("file.xml",System.Text.Encoding.UTF8);
        writer.Formatting = Formatting.Indented;
        document.WriteTo( writer );
        writer.Flush();
        writer.Close();
        }

        Thank you.

        R Offline
        R Offline
        Ryan Cromwell
        wrote on last edited by
        #3

        Cause it's static.

        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