I have a code section looking like this:
XDocument xml = new XDocument(
new XElement("test1",
new XElement("test2", "abc")
)
);
I now want to save the xml document using the Save method:
xml.Save("test.xml");
Then I took a look at the file using a hex editor and noticed that it has windows line endings (/r/n). However, I "only" need UNIX line endings (/n).
Thanks in advance!
You need to create an XmlWriter
:
using (var w = XmlWriter.Create(path, new XmlWriterSettings {
NewLineChars = "\n",
}))
{
xml.Save(w);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With