title: How to convert stream reader response to a class object?
body: <p>I am currently working on some functionality that makes an httppost then get a response.</p>
  
  <p>Here's the code I'm currently working with:</p>
  
  <pre><code>public string SubmitRequest(string postUrl, string contentType, string postValues)
      {
          var req = WebRequest.Create(postUrl);
          req.Method = "POST";
          req.ContentType = contentType;
  
          try
          {
              using (var reqStream = req.GetRequestStream())
              {
                  var writer = new StreamWriter(reqStream);
                  writer.WriteLine(postValues);
              }
  
              var resp = req.GetResponse();
  
              using (var respStream = resp.GetResponseStream())
              {
                  var reader = new StreamReader(respStream);
                  return reader.ReadToEnd().Trim();
              }
  
          }
          catch(WebException ex)
          {
              // do something here
          }
  
          return string.Empty;
      }
  </code></pre>
  
  <p>The function returns xml in string format, for instance:</p>
  
  <pre><code>&lt;result&gt;
    &lt;code&gt;Failed&lt;/code&gt;
    &lt;message&gt;Duplicate Application&lt;/message&gt;
  &lt;/result&gt;
  </code></pre>
  
  <p>This needs to be converted into a class object - but i'm not sure how to go about it in the correct way.</p>
  
  <p>Any advice appreciated.</p>