|
|
От: | Arsen.Shnurkov | |
| Дата: | 14.09.16 17:33 | ||
| Оценка: | |||
Mind that PreserveWhitespace preserves only elements indentation. If you have attributes in new lines or multiline values they will be reformatted.
I believe that LoadOptions.PreserveWhitespace and SaveOptions.DisableFormatting only instruct XDocument on how to handle whitespace in terms of indentation and the content of text nodes. It would still normalize the attributes, etc.
You may wish to use an overload where you specify an XmlWriter that is configured to do what you want, and if you can't find a configuration that works with the default XmlTextWriter, you could always create your own XmlWriter.
XDocument.Save has a SaveOptions argument which can be set to disable formatting. This has the same effect as putting the XmlWriterSettings "Indent" property to "false"