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. How can I add standalone="no" in creating an XML file?

How can I add standalone="no" in creating an XML file?

Scheduled Pinned Locked Moved C#
questionxmlhelp
8 Posts 3 Posters 3 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.
  • U Offline
    U Offline
    User 10603967
    wrote on last edited by
    #1

    I am able to create a XML file with:

    with the following codes:

    XmlWriterSettings settings = new XmlWriterSettings();
    settings.Indent = true;
    settings.Encoding = Encoding.GetEncoding("ISO-8859-1");

            XmlWriter writer = XmlWriter.Create("C:\\\\XML files\\\\XML\_File.xml", settings);
    

    How can I add standalone="no" after encoding="ISO-8859-1" as

    Thanks for any help :doh:

    T F 2 Replies Last reply
    0
    • U User 10603967

      I am able to create a XML file with:

      with the following codes:

      XmlWriterSettings settings = new XmlWriterSettings();
      settings.Indent = true;
      settings.Encoding = Encoding.GetEncoding("ISO-8859-1");

              XmlWriter writer = XmlWriter.Create("C:\\\\XML files\\\\XML\_File.xml", settings);
      

      How can I add standalone="no" after encoding="ISO-8859-1" as

      Thanks for any help :doh:

      T Offline
      T Offline
      thatraja
      wrote on last edited by
      #2

      This page[^] has answer. And also check this method[^]

      thatraja

      Code converters | Education Needed | Improve EverythingNew

      U 1 Reply Last reply
      0
      • T thatraja

        This page[^] has answer. And also check this method[^]

        thatraja

        Code converters | Education Needed | Improve EverythingNew

        U Offline
        U Offline
        User 10603967
        wrote on last edited by
        #3

        When I use the link and set:

        writer.WriteStartDocument(true)

        ; then I have

        However when I set:

        writer.WriteStartDocument(false)

        ; then I have

        *) What I need as mentionned before:

        Thanks for help, we are close! :doh:

        T 1 Reply Last reply
        0
        • U User 10603967

          I am able to create a XML file with:

          with the following codes:

          XmlWriterSettings settings = new XmlWriterSettings();
          settings.Indent = true;
          settings.Encoding = Encoding.GetEncoding("ISO-8859-1");

                  XmlWriter writer = XmlWriter.Create("C:\\\\XML files\\\\XML\_File.xml", settings);
          

          How can I add standalone="no" after encoding="ISO-8859-1" as

          Thanks for any help :doh:

          F Offline
          F Offline
          Francine DeGrood Taylor
          wrote on last edited by
          #4

          I had the same problem. I had to go with XmlDocument: XmlNode docNode = doc.CreateXmlDeclaration("1.0", "iso-8859-1", "no"); I'm guessing you are viewing this in a browser instead of a text file. One thing that you may notice is that the "ISO" becomes capitalized in a browser, but if you look at it with a text editor like Notepad, it looks the way you want it. Also, the browser translates "no" to "false". If you want to see what it looks like exactly, use Notepad. You might also try this: XmlSerializer xmlSer = new XmlSerializer(typeof(T)); using (MemoryStream mem = new MemoryStream()) { using (XmlWriter writer = XmlWriter.Create(mem)) { string doubleQuote = ((char)34).ToString(); string s = "version=" + doubleQuote + "1.0" + doubleQuote + " encoding=" + doubleQuote + "iso-8859-1" + doubleQuote + " standalone=" + doubleQuote + "no" + doubleQuote; writer.WriteProcessingInstruction("xml", s); xmlSer.Serialize(writer, objectToSerialize); } }

          U 2 Replies Last reply
          0
          • U User 10603967

            When I use the link and set:

            writer.WriteStartDocument(true)

            ; then I have

            However when I set:

            writer.WriteStartDocument(false)

            ; then I have

            *) What I need as mentionned before:

            Thanks for help, we are close! :doh:

            T Offline
            T Offline
            thatraja
            wrote on last edited by
            #5

            Clickety[^]

            thatraja

            Code converters | Education Needed | Improve EverythingNew

            U 1 Reply Last reply
            0
            • F Francine DeGrood Taylor

              I had the same problem. I had to go with XmlDocument: XmlNode docNode = doc.CreateXmlDeclaration("1.0", "iso-8859-1", "no"); I'm guessing you are viewing this in a browser instead of a text file. One thing that you may notice is that the "ISO" becomes capitalized in a browser, but if you look at it with a text editor like Notepad, it looks the way you want it. Also, the browser translates "no" to "false". If you want to see what it looks like exactly, use Notepad. You might also try this: XmlSerializer xmlSer = new XmlSerializer(typeof(T)); using (MemoryStream mem = new MemoryStream()) { using (XmlWriter writer = XmlWriter.Create(mem)) { string doubleQuote = ((char)34).ToString(); string s = "version=" + doubleQuote + "1.0" + doubleQuote + " encoding=" + doubleQuote + "iso-8859-1" + doubleQuote + " standalone=" + doubleQuote + "no" + doubleQuote; writer.WriteProcessingInstruction("xml", s); xmlSer.Serialize(writer, objectToSerialize); } }

              U Offline
              U Offline
              User 10603967
              wrote on last edited by
              #6

              Yes, you are right about seeing it with Notepad which I have: Thanks for clarifying it :)

              1 Reply Last reply
              0
              • F Francine DeGrood Taylor

                I had the same problem. I had to go with XmlDocument: XmlNode docNode = doc.CreateXmlDeclaration("1.0", "iso-8859-1", "no"); I'm guessing you are viewing this in a browser instead of a text file. One thing that you may notice is that the "ISO" becomes capitalized in a browser, but if you look at it with a text editor like Notepad, it looks the way you want it. Also, the browser translates "no" to "false". If you want to see what it looks like exactly, use Notepad. You might also try this: XmlSerializer xmlSer = new XmlSerializer(typeof(T)); using (MemoryStream mem = new MemoryStream()) { using (XmlWriter writer = XmlWriter.Create(mem)) { string doubleQuote = ((char)34).ToString(); string s = "version=" + doubleQuote + "1.0" + doubleQuote + " encoding=" + doubleQuote + "iso-8859-1" + doubleQuote + " standalone=" + doubleQuote + "no" + doubleQuote; writer.WriteProcessingInstruction("xml", s); xmlSer.Serialize(writer, objectToSerialize); } }

                U Offline
                U Offline
                User 10603967
                wrote on last edited by
                #7

                Yes, you are right which writer.WriteStartDocument(false); I do have if seeing it with Notepad. Thanks for clarifying it ;)

                1 Reply Last reply
                0
                • T thatraja

                  Clickety[^]

                  thatraja

                  Code converters | Education Needed | Improve EverythingNew

                  U Offline
                  U Offline
                  User 10603967
                  wrote on last edited by
                  #8

                  Thanks for the link, it is OK if I viewing my xml file with Notepad! :-D

                  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