title: How to set XmlReader with HttpWebResponse
body: <p>I've been having an issue taking a HttpWebResponse and setting it to an XmlReader, with the examples I've looked up so far I've gotten this:</p>
  
  <pre><code>HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  XmlReader xmlReader;
  if (response != null)
  {
      StreamReader sr = new StreamReader(response.GetResponseStream());
      //string st = sr.ReadToEnd().Trim();
      xmlReader = XmlReader.Create(sr);
  }
  </code></pre>
  
  <p>But the problem is that xmlReader does not get filled with the entire response, I get a partial response that isn't even valid XML(no closing tags on some nodes) which causes issues when trying to read from that variable later on.</p>
  
  <p>But if I uncomment the following line for testing:</p>
  
  <pre><code>string str = sr.ReadtoEnd().Trim();
  </code></pre>
  
  <p>The variable str is filled with the entire XML response, but obviously I need it in a form of a XmlReader so I can run LINQ to XML on it.</p>
  
  <p>My question is, what is the best way to be sure that I get the entire response in the XmlReader object?</p>