Write XML with formating

Discussion in 'ASP .Net' started by David, Mar 6, 2005.

  1. David

    David Guest

    Hi,

    My asp.net application is writing a few xml files based on certain criteria.
    the application works like this.
    1. read an xml template using LoadXML.
    2. manipulate the xml and add certain values
    3. write the xml out to a file.

    now i am achieveing this no problem, however when i write the xml to file it
    basically come out as a single long string.
    upon opening the file in IE it is formatted beautifully.

    I would like to write the xml to file in the formated fashion, is this
    possible.
    I don't want to have to hardcode xml attribute names in case the schema of
    the XML template changes.
    I merely want to read XML from a formatted template, manipulate it and then
    write it to a file and keep the formatting / indentation.

    any help is appreciated.


    cheers

    martin.
     
    David, Mar 6, 2005
    #1
    1. Advertising

  2. Hi!
    It's the IE that formats the XML, as you have noticed. So if you want to see
    the XML formatted, you have to write some code to see it formatted. But your
    wish to "write the xml to file in the formated fashion" sounds like to write
    one html page formatted (with the images, tables...) in a file instead of
    saving the tags in the file...
    See, the thing is that you must follow some rules, so your browser can
    understand what is written in the file

    Hope that helps!
    Regards,
    Kostadin Kostov

    "David" wrote:

    > Hi,
    >
    > My asp.net application is writing a few xml files based on certain criteria.
    > the application works like this.
    > 1. read an xml template using LoadXML.
    > 2. manipulate the xml and add certain values
    > 3. write the xml out to a file.
    >
    > now i am achieveing this no problem, however when i write the xml to file it
    > basically come out as a single long string.
    > upon opening the file in IE it is formatted beautifully.
    >
    > I would like to write the xml to file in the formated fashion, is this
    > possible.
    > I don't want to have to hardcode xml attribute names in case the schema of
    > the XML template changes.
    > I merely want to read XML from a formatted template, manipulate it and then
    > write it to a file and keep the formatting / indentation.
    >
    > any help is appreciated.
    >
    >
    > cheers
    >
    > martin.
    >
    >
    >
    >
     
    =?Utf-8?B?S29zdGFkaW4gS29zdG92?=, Mar 6, 2005
    #2
    1. Advertising

  3. David

    Matt Berther Guest

    Hello David,

    Assuming you're using an XmlWriter, you can set the Formatting property to
    Indented and IndentLevel to some value (probably 2 or 4).

    --
    Matt Berther
    http://www.mattberther.com

    > Hi,
    >
    > My asp.net application is writing a few xml files based on certain
    > criteria.
    > the application works like this.
    > 1. read an xml template using LoadXML.
    > 2. manipulate the xml and add certain values
    > 3. write the xml out to a file.
    > now i am achieveing this no problem, however when i write the xml to
    > file it
    > basically come out as a single long string.
    > upon opening the file in IE it is formatted beautifully.
    > I would like to write the xml to file in the formated fashion, is this
    > possible.
    > I don't want to have to hardcode xml attribute names in case the
    > schema of
    > the XML template changes.
    > I merely want to read XML from a formatted template, manipulate it and
    > then
    > write it to a file and keep the formatting / indentation.
    > any help is appreciated.
    >
    > cheers
    >
    > martin.
    >
     
    Matt Berther, Mar 6, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rodrigo guerra

    automatic code formating...

    rodrigo guerra, Jul 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    359
    rodrigo guerra
    Jul 5, 2003
  2. Dmitri Manushin

    Formating text

    Dmitri Manushin, Aug 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    386
    Dmitri Manushin
    Aug 14, 2003
  3. John Carnahan

    Help on date formating

    John Carnahan, Nov 19, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    315
    Alvin Bruney
    Nov 19, 2003
  4. Fabiano

    Formating BoundColumn Items

    Fabiano, Nov 29, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    352
    Kaustav Neogy
    Nov 29, 2003
  5. Draggi

    formating the XML response in webservice

    Draggi, Dec 27, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    128
    Draggi
    Dec 29, 2005
Loading...

Share This Page