title: Want to return the entire contents of an XElement as a string
body: <p>I'm a newbie to LINQ in C# and am using it to read in and work with XML files.</p>
  
  <p>I'm able to navigate up and down my elements, but what I want for some elements is to return the <em>entire</em> contents as a string.  Meaning, I have an element like this:</p>
  
  <pre><code>&lt;element1&gt;
      &lt;subel1&gt; some text here &lt;/subel1&gt;
  &lt;/element1&gt;
  </code></pre>
  
  <p>When I get the value of element1, I want to get back the entire contents as a text string like this:  <code>"&lt;subel1&gt; some text here &lt;/subel1&gt;"</code></p>
  
  <p>Does that make sense?  Can anyone help?</p>
  
  <p>(closed as duplicate of <a href="https://stackoverflow.com/questions/3793/best-way-to-get-innerxml-of-an-xelement">here</a>)</p>