title: linq to xml: How to get value of a tag in an element in C#
body: <p>I have following xml data.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;mail&gt;
    &lt;id&gt;signUpConfirmation&lt;/id&gt;
    &lt;subject&gt;Activation&lt;/subject&gt;
    &lt;body&gt;
  Hi, You account is activated \nRegards
  &lt;/body&gt;
  &lt;/mail&gt;
  </code></pre>
  
  <p>I need to read value from <code>&lt;body&gt;</code> tag depending on id I pass.</p>
  
  <p>This is what I have tried</p>
  
  <pre><code>var xml = File.ReadAllText("C:\\Users\\DELL\\Documents\\Visual Studio 2012\\Projects\\Website\\Website\\Files\\Mails.xml");
  
  var str = XElement.Parse(xml);
  var result = from mail in str.Elements("mail")
               where (string)mail.Element("id") == "signUpConfirmation"
               select (string)mail.Element("body");
  log.Debug("mail data:" + result.First());
  </code></pre>
  
  <p>I get error : </p>
  
  <blockquote>
    <p>Sequence contains no elements.</p>
  </blockquote>
  
  <p>Also, I want to access the value of id tag as well in the same query.</p>