This is probably the least sophisticated answer, but I solved it for me whith a simple string replace.
.Replace(" xsi:nil=\"true\" ", "");
I'm serializing to string first anyway. I can save to file later.
It keeps all my XmlWriterSettings intact. One other solution I found her messed it up:)
private static string Serialize<T>(T details)
{
var serializer = new XmlSerializer(typeof(T));
using (var ms = new MemoryStream())
{
var settings = new XmlWriterSettings
{
Encoding = Encoding.GetEncoding("ISO-8859-1"),
NewLineChars = Environment.NewLine,
ConformanceLevel = ConformanceLevel.Document,
Indent = true,
OmitXmlDeclaration = true
};
using (var writer = XmlWriter.Create(ms, settings))
{
serializer.Serialize(writer, details);
return Encoding.UTF8.GetString(ms.ToArray()).Replace(" xsi:nil=\"true\" ", "");
}
}
}
xsi:nil="true"
nodes. – Hunker