By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,156 Members | 962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,156 IT Pros & Developers. It's quick & easy.

Write XML with formating

P: n/a
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.

Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

Nov 19 '05 #2

P: n/a
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.


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.