all groups > dotnet xml > march 2006 >
You're in the

dotnet xml

group:

Using XmlDocument.Save removes previous formatting of the file


Using XmlDocument.Save removes previous formatting of the file Aaron Sellers
3/27/2006 2:03:08 PM
dotnet xml:
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

Re: Using XmlDocument.Save removes previous formatting of the file Cerebrus
3/27/2006 2:47:16 PM
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.
Re: Using XmlDocument.Save removes previous formatting of the file Aaron Sellers
3/28/2006 8:49:47 AM
Thanks so much, Cerebrus.

Re: Using XmlDocument.Save removes previous formatting of the file Cerebrus
3/28/2006 9:42:18 AM
Most welcome...

Happy coding,

Regards,

Cerebrus.
AddThis Social Bookmark Button