title: Load xml using XDocument.Load error "root element is missing" from stream
body: <p>I got problems in using XDocument.Load because sometimes there is no error and sometimes there is already error, same error "root element is missing" I already tried using seek and position still the same error occurs.</p>
  
  <p>Any ideas how can I fix this issue? Thanks</p>
  
  <p>Here is my source code so far:</p>
  
  <pre><code>using (var stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
          {
              stream.Seek(0, System.IO.SeekOrigin.Begin);
              //stream.Position = 0;
              var request = XDocument.Load(stream);
              var get_command = from r in request.Descendants("Transaction")
                                select new
                                {
                                    Type = r.Element("Type").Value
                                };
  
              foreach (var c in get_command)
              {
                  type = c.Type;
              }
          }
  </code></pre>
  
  <p>Sample XML</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Request&gt;
    &lt;Transaction&gt;
      &lt;Type&gt;gc&lt;/Type&gt;
    &lt;/Transaction&gt;
  &lt;/Request&gt;
  </code></pre>