title: Parsing unusual XML with Linq
body: <p>I get a peculiar response back from a webservice:</p>
  
  <pre><code>&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;soap:Body&gt;
      &lt;GetLemonadeResponse xmlns="http://microsoft.com/webservices/"&gt;
        &lt;GetLemonadeResult&gt;&amp;lt;Response&amp;gt;&amp;lt;Status&amp;gt;Error&amp;lt;/Status&amp;gt;&amp;lt;Message&amp;gt;Could not find the Lemonade for this State/Lemon&amp;lt;/Message&amp;gt;&amp;lt;FileNumber /&amp;gt;&amp;lt;/Response&amp;gt;&lt;/GetLemonadeResult&gt;
      &lt;/GetLemonadeResponse&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>2 questions:</p>
  
  <p>1) I am not sure why the content of GetLemonadeResult has deviant content (like "&amp; l t ;").</p>
  
  <p>I migrate the bytes to string this way:</p>
  
  <pre><code>WebClientEx client = new WebClientEx();
  client.Headers.Add(HttpRequestHeader.ContentType, "text/xml; charset=utf-8");
  client.Encoding = Encoding.UTF8;
  byte[] result = client.UploadData(_baseUri.ToString(), data);
  client.Encoding.GetBytes(xml));
  string resultString = client.Encoding.GetString(result);
  </code></pre>
  
  <p>(WebClientEx derives from WebClient with an extra Timeout property).</p>
  
  <p>I am thinking if I picked the wrong encoding the outer part of the response would be mangled the same way.</p>
  
  <p>Does the web service have an error?</p>
  
  <p>2) Why is it that when I try to grab "GetLemonadeResult" using Linq to XML it can't pull anything?</p>
  
  <pre><code>var xdoc = XDocument.Parse(response); // returns the XML posted above
  var responseAsXML = xdoc.Descendants("GetLemonadeResult"); // gets nothing
  </code></pre>
  
  <p>I wouldn't have guessed I'd need a namespace to catch the descendants since the XML GetLemonadeResult tag doesn't have a prepending "tag:".</p>