Linq to Xml - Input String <p>I am using Linq to Xml to parse some xml messages coming from a legacy system. One of the messages is coming in as Name / Value pairs. So I am doing the lookup by name and then trying to get the equivalent value. However, when the Value is blank (<code>&lt;Value/&gt;</code>) my code is throwing the error <code>Input string was not in a correct format.</code></p> <p>I am trying to figure out the best way to solve this issue. Any suggestions would be greatly appreciated (Trying to fill property with nullable int type int?). </p> <p>Code Example:</p> <pre><code>myRecord.myField= xdoc.Descendants("Information") .Where(x =&gt; (string)x.Element("Name") == "myField") .Select(x =&gt; (int?)x.Element("Value")).FirstOrDefault(); </code></pre> <p>XML Snippet:</p> <pre><code> &lt;Information&gt; &lt;Name&gt;myField&lt;/Name&gt; &lt;Value /&gt; &lt;/Information&gt; </code></pre> <p>Always appreciate the feedback / input.</p> <p>Thanks,</p> <p>S</p>