Write XML with formating

D

David

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.
 
G

Guest

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
 
M

Matt Berther

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).
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top