title: Root element is missing when load XmlDocument from a stream
body: <p>I have the following code:</p>
  
  <pre><code>var XmlDoc = new XmlDocument();
  Console.WriteLine();
  Console.WriteLine(response.ReadToEnd());
  Console.WriteLine();
  
  // setup the XML namespace manager
  XmlNamespaceManager mgr = new XmlNamespaceManager(XmlDoc.NameTable);
  // add the relevant namespaces to the XML namespace manager
  mgr.AddNamespace("ns", "http://triblue.com/SeriousPayments/");
  XmlDoc.LoadXml(response.ReadToEnd());
  XmlElement NodePath = (XmlElement)XmlDoc.SelectSingleNode("/ns:Response", mgr);
  
  while (NodePath != null)
    {
        foreach (XmlNode Xml_Node in NodePath)
        {
            Console.WriteLine(Xml_Node.Name + " " + Xml_Node.InnerText);
        }
    }
  </code></pre>
  
  <p>I am getting:</p>
  
  <blockquote>
    <p>Root element is missing.</p>
  </blockquote>
  
  <p>at:</p>
  
  <pre><code>XmlDoc.LoadXml(response.ReadToEnd());
  </code></pre>
  
  <p>My XML looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://triblue.com/SeriousPayments/"&gt;
      &lt;Result&gt;0&lt;/Result&gt;
      &lt;Message&gt;Pending&lt;/Message&gt;
      &lt;PNRef&gt;230828&lt;/PNRef&gt;
      &lt;ExtData&gt;InvNum=786&lt;/ExtData&gt;
  &lt;/Response&gt;
  </code></pre>
  
  <p>I'm lost. Can someone tell me what I'm doing wrong? I know I had this working before so I'm not sure what I screwed up.</p>
  
  <p>As always, thanks!</p>
  
  <p><em><strong></em>* Reason for my edit after I got my answer <em>*</em>*</strong></p>
  
  <p>I needed to change the line:</p>
  
  <pre><code>XmlElement NodePath = (XmlElement)XmlDoc.SelectSingleNode("/ns:Response");
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>XmlElement NodePath = (XmlElement)XmlDoc.SelectSingleNode("/ns:Response", mgr);
  </code></pre>
  
  <p>This will not work without it.</p>