473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Using XmlDocument.Save removes previous formatting of the file

Hi all,
I have a nicely formatted .xml file that loses that nice formatting when
I edit it and use XmlDocument.Save to save the file. Does anyone know of
any way to keep the formatting I had when I opened the file?

Thanks!

Aaron Sellers
Mar 27 '06 #1
3 2361
Hi Aaron,

The XmlDocument.PreserveWhitespace property is what you need. Set it to
True before Loading the XML document, and all whitespace is preserved.
Set it to True before Saving, and your whitespace will be preserved.

BTW, "XmlDocument.Save" auto-indents the output which you save.

HTH,

Regards,

Cerebrus.

Mar 27 '06 #2
Thanks so much, Cerebrus.
Mar 28 '06 #3
Most welcome...

Happy coding,

Regards,

Cerebrus.

Mar 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tom Pearson | last post by:
I have created an XmlDocument and can see that this is correctly formed and has a root element If I Save the doc to a file and reload it all works o If I dump the doc to a stream, again using the...
0
by: Murali | last post by:
I am using XmlDocument Object to open SVG File. Its working fine some PCs. On Some PCs its giving Operation Timeout Error. Dim objXML As New XmlDocument Try...
3
by: TS | last post by:
HI, is there any option while using appendChild so that it doesn't do the autotomatic indentation and line breaks so that the tags are appended back to back? thanks
1
by: st | last post by:
Hi, I'm using xmlDocument.Save(xmlTextWriter) to create an Excel-readable file. All works well, except where I've replaced the carriage return chars in the .innertext to XML-compliant " "; It...
4
by: Carl Williams | last post by:
Hope someone can help with this... I have looked at all the newsgroup articles and put into practice all the suggestions but to no good. I am pretty new to CSharp and .Net so any help would be...
2
by: Terry | last post by:
When using XMLDocument.Save(strFileName) in .NET 2005, is there a way to check (or trap) and see if the file is in use by another. I am using VB.NET. Currently it just bombs and says the filename...
1
by: liuhengyi | last post by:
Hi, I have a test program that creates 5 threads and each thread uses XmlDocument.Save(filename) to save a Xml dom to a file. I have put the lock statement around the Save to prevent from...
0
by: liuhengyi | last post by:
Hi, I have a test program that creates 5 threads and each thread uses XmlDocument.Save(filename) to save a Xml dom to a file. I have put the lock statement around the Save to prevent concurrent...
2
by: yxq | last post by:
I want to add some elements to a XML file using XmlDocument, how to do? thank you very much. The original XML file like: //////////////////////////////////////////////////////// <?xml...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.