title: System.Xml.XmlException: Unexpected end of file while parsing Name has occurred
body: <p>I'm using an <code>XmlReader</code> retrieved using <code>SqlCommand.ExecuteXmlReader</code>.</p>
  
  <p><a href="https://gist.github.com/codyherring/5193077" rel="nofollow noreferrer">Here is my input</a></p>
  
  <p>When I run this line of code:</p>
  
  <pre><code>XDocument currentXDoc = XDocument.Load(ktXmlReader.ReadSubtree());
  </code></pre>
  
  <p>it works the first time, reading in the first Product node as expected.</p>
  
  <p>The second time it runs, I get the following exception:</p>
  
  <pre><code>System.Xml.XmlException:
  Message: Unexpected end of file while parsing Name has occurred. Line 1, position 2048.
  
  Stacktrace:    at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
     at System.Xml.XmlTextReaderImpl.ParseQName(Boolean isQName, Int32 startOffset, Int32&amp; colonPos)
     at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag)
     at System.Xml.XmlTextReaderImpl.ParseEndElement()
     at System.Xml.XmlTextReaderImpl.ParseElementContent()
     at System.Xml.XmlSubtreeReader.Read()
     at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
     at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
     at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
  </code></pre>
  
  <p>I did find <a href="https://stackoverflow.com/questions/12447208/unexpected-end-of-file-in-c-sharp-while-reading-georss-feed">this question</a> and <a href="https://stackoverflow.com/questions/9083094/web-service-call-unexpected-end-of-file-while-parsing-name-has-occurred">this question</a> that were similar to mine, but I'm fairly sure my XML is well-formed (I can get it directly from running a sproc)</p>
  
  <p>My ideas so far:</p>
  
  <ol>
  <li>2048 is a very suspicious number in computers.  Am I running into a 2KB limit somewhere in <code>XDocument</code> or <code>XmlReader</code>?</li>
  <li>My ktXmlReader.Read() in the while loop is somehow skipping all the other nodes and going straight to the EOF</li>
  </ol>