XAttribute null even though it is there? : <p>doc = GetSecureXDocument("<a href="https://www.predictit.org/api/marketdata/all" rel="nofollow noreferrer">https://www.predictit.org/api/marketdata/all</a>");</p>

<pre><code>            List &lt;MarketContract&gt; contracts = doc.Root.Element("Markets").Elements("MarketData").Elements("Contracts").Elements("MarketContract").Select(x =&gt; new MarketContract
        {
            //ID = int.Parse((string)x.Attribute("ID")),
            URL = (string)x.Attribute("URL"),
            Name = (string)x.Attribute("Name"),
            LongName = (string)x.Attribute("LongName"),
            ShortName = (string)x.Attribute("ShortName"),
            TickerSymbol = (string)x.Attribute("TickerSymbol"),
            Status = (string)x.Attribute("Status"),
            /*BestBuyNoCostInCents = int.Parse((string)x.Attribute("BestBuyNoCost")),
            BestBuyYesCostInCents = int.Parse((string)x.Attribute("BestBuyYesCost")),
            BestSellNoCostInCents = int.Parse((string)x.Attribute("BestSellNoCost")),
            BestSellYesCostInCents = int.Parse((string)x.Attribute("BestSellYesCost"))*/
        }).ToList();
</code></pre>

<p>The commented out sections throw nullargumentexceptions, and when the values of URL, Name, LongName etc are printed, they're all zero.</p>

<p>Here's the value of 'x' in the lambda during a run:</p>

<pre><code>    &lt;MarketContract&gt;
  &lt;ID&gt;3414&lt;/ID&gt;
  &lt;DateEnd&gt;N/A&lt;/DateEnd&gt;
  &lt;Image&gt;https://az620379.vo.msecnd.net/images/Contracts/small_f6d2f26b-8055-45a3-872f-0796dc47e238.png&lt;/Image&gt;
  &lt;URL&gt;https://www.predictit.org/Contract/3414/Will-a-Democratic-candidate-win-the-2017-Virginia-gubernatorial-race&lt;/URL&gt;
  &lt;Name&gt;Democratic&lt;/Name&gt;
  &lt;LongName&gt;Will a Democratic candidate win the 2017 Virginia gubernatorial race?&lt;/LongName&gt;
  &lt;ShortName&gt;Democratic&lt;/ShortName&gt;
  &lt;TickerSymbol&gt;DEM.VAGOV17&lt;/TickerSymbol&gt;
  &lt;Status&gt;Open&lt;/Status&gt;
  &lt;LastTradePrice&gt;0.75&lt;/LastTradePrice&gt;
  &lt;BestBuyYesCost&gt;0.78&lt;/BestBuyYesCost&gt;
  &lt;BestBuyNoCost&gt;0.26&lt;/BestBuyNoCost&gt;
  &lt;BestSellYesCost&gt;0.74&lt;/BestSellYesCost&gt;
  &lt;BestSellNoCost&gt;0.22&lt;/BestSellNoCost&gt;
  &lt;LastClosePrice&gt;0.75&lt;/LastClosePrice&gt;
&lt;/MarketContract&gt;
</code></pre>

<p>This is my first time dealing with XML, and if anyone could help, that would be greatly appreciated!</p>
