XML file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • R.A.F.

    #1

    XML file

    Hi,

    I would like to know if there is a particular method to create a blank
    XML file, with only following lines:

    <?xml version="1.0" encoding="utf-8"?>
    <Settings>
    </Settings>

    where <Settingsis the root node.

    thx.

    RAF
  • Kerem Gümrükcü

    #2
    Re: XML file

    Please use your real name!



    Regards

    Kerem

    -----------------------
    Beste Grüsse / Best regards / Votre bien devoue
    Kerem Gümrükcü
    kerem.g@arcor.d e

    Best Quote: "Ain't nobody a badass with a double dose
    of rock salt...", Kill Bill Vol.2

    Microsoft Live Space: http://kerem-g.spaces.live.com/
    Latest Open-Source Projects: http://entwicklung.junetz.de
    Sign my guestbook: http://entwicklung.junetz.de/guestbook/
    -----------------------
    "This reply is provided as is, without warranty express or implied."


    Comment

    • Jon Skeet [C# MVP]

      #3
      Re: XML file

      Kerem Gümrükcü <kareem114@hotm ail.comwrote:
      Please use your real name!
      While I personally prefer it when people use their real names, I don't
      really have anything against pseudonyms. I certainly don't think it's
      worth telling people off about.

      --
      Jon Skeet - <skeet@pobox.co m>
      http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
      World class .NET training in the UK: http://iterativetraining.co.uk

      Comment

      • R.A.F.

        #4
        Re: XML file

        sorry but RAF are the first letters of my real name
        R.A.F :-)

        as it is quite long i prefer to make it shorted like that.

        Kerem Gümrükcü wrote:
        Please use your real name!
        >
        >
        >
        Regards
        >
        Kerem
        >
        -----------------------
        Beste Grüsse / Best regards / Votre bien devoue
        Kerem Gümrükcü
        kerem.g@arcor.d e
        >
        Best Quote: "Ain't nobody a badass with a double dose
        of rock salt...", Kill Bill Vol.2
        >
        Microsoft Live Space: http://kerem-g.spaces.live.com/
        Latest Open-Source Projects: http://entwicklung.junetz.de
        Sign my guestbook: http://entwicklung.junetz.de/guestbook/
        -----------------------
        "This reply is provided as is, without warranty express or implied."
        >
        >

        Comment

        • Nicholas Paldino [.NET/C# MVP]

          #5
          Re: XML file

          I hate to point out the obvious, but why not just do this:

          string xml = "<?xml version="1.0"
          encoding=\"utf-8\"?><Settings> </Settings>";

          And then just save that to a file?

          --
          - Nicholas Paldino [.NET/C# MVP]
          - mvp@spam.guard. caspershouse.co m

          "R.A.F." <noemail@nospam .comwrote in message
          news:OoDEUhTLIH A.5580@TK2MSFTN GP02.phx.gbl...
          Hi,
          >
          I would like to know if there is a particular method to create a blank XML
          file, with only following lines:
          >
          <?xml version="1.0" encoding="utf-8"?>
          <Settings>
          </Settings>
          >
          where <Settingsis the root node.
          >
          thx.
          >
          RAF

          Comment

          • Marc Gravell

            #6
            Re: XML file

            NPI hate to point out the obvious, but...
            yup -first thing that occurred to me too (see post)

            RAFi was looking for something better formatted
            I realise that you're sorted, but for completeness there is an
            XmlWriterSettin gs object that controls this type of thing.

            Marc

            Comment

            • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

              #7
              Re: XML file

              Kerem Gümrükcü wrote:
              Please use your real name!
              It happen frequently that people use usenet under initials
              or other forms for anonymity.

              Not a problem (as long as they do not behave in such a bad way
              that it becomes relevant to know who they really are).

              Arne


              Comment

              • Marc Gravell

                #8
                Re: XML file

                I didn't see anyone mention:
                Because that won't create a file - it will just load a DOM. Yes you
                could call Save(), but if you're going down the literal route, then
                the DOM is unnecessary - just use:
                File.WriteAllTe xt(path, "<?xml......>") ;
                which both Nicholas any myself hinted at.

                Marc

                Comment

                • R.A.F.

                  #9
                  Re: XML file

                  Hi Nicholas,

                  i do not do that, because those XML files are built in several steps.
                  moreover, such a string is good, but once i will need to use the other
                  XML methods and it's better (from my point of view :-) to standardize my
                  process.

                  RAF

                  Nicholas Paldino [.NET/C# MVP] wrote:
                  I hate to point out the obvious, but why not just do this:
                  >
                  string xml = "<?xml version="1.0"
                  encoding=\"utf-8\"?><Settings> </Settings>";
                  >
                  And then just save that to a file?
                  >

                  Comment

                  Working...