Question: I want to serialize an object where some of the member variables are of type `string` and have the value `null`.
I use the following code:

```
        var writer = new XmlTextWriter(stream, Encoding.UTF8);
        writer.Formatting = Formatting.Indented;

        var s = new XmlSerializer(typeof(model.GetType()));            
        s.Serialize(writer, model);

```

The strings with value `null` don't appear in the Xml file (which is obviously intended behavior), although I don't want that. 
How can I make `null` strings appear in the Xml file by overriding the `XmlTextWriter` class?

EDIT: I can't modify the object model that needs to be serialized, so Xml attributes are no option.

Answer: 
You could use:

```
[XmlElement(IsNullable = true)]

```

on any member you want to be written on file even if null.
I suggest cloning the ObjektModleTree and replacing "null" String with empty ones.

Inherit the XmlSerializer in a new class and clone the ObjectModelTree without the "null" strings.
So if you are able to change the ObjektModel you can remove your own Serializer and use the .NET Serializer to do the work.