<p>I wanted to deserialize an XML message containing an element that can be marked <code>nil="true"</code> into a class with a property of type <code>int?</code>. The only way I could get it to work was to write my own <code>NullableInt</code> type which implements <code>IXmlSerializable</code>. Is there a better way to do it?</p>

<p>I wrote up the full problem and the way I solved it <a href="http://alexscordellis.blogspot.com/2008/11/using-xmlserializer-to-deserialize-into.html" rel="nofollow noreferrer">on my blog</a>.</p>

I think you need to prefix the nil="true" with a namespace in order for XmlSerializer to deserialise to null.
MSDN on xsi:nil
```
```
<?xml version="1.0" encoding="UTF-8"?>
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="array">
  <entity>
    <id xsi:type="integer">1</id>
    <name>Foo</name>
    <parent-id xsi:type="integer" xsi:nil="true"/>
```
```