title: XML to String List
body: <p>I have some code that I need to put into a string list in C# and I am reading this code from an XML files and the layout of it is something like below...</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;accountlist&gt;
      &lt;main&gt;
          &lt;account id="1" special_id="4923959"&gt;
              &lt;username&gt;Adam&lt;/username&gt;
              &lt;motto&gt;Hello Everyone&gt;
              &lt;money&gt;1004&lt;/money&gt;
              &lt;friends&gt;394&lt;/friends&gt;
              &lt;rareid&gt;9&lt;/rareid&gt;
              &lt;mission&gt;10&lt;/mission&gt;
          &lt;/account&gt;
      &lt;/main&gt;
  &lt;/accountlist&gt;
  </code></pre>
  
  <p>How can I put each account tag into a string list? from the first &lt; account > to the &lt; / account > tag?</p>
  
  <p>Please do NOT  tell me to go to the link below as it does NOT work!!
  <a href="https://stackoverflow.com/questions/9619324/how-to-read-a-xml-file-and-write-into-list">How to read a XML file and write into List&lt;&gt;?</a></p>
  
  <p>So far I have tried the below code, and the string list just stays empty</p>
  
  <pre><code>XDocument doc = XDocument.Parse(this._accountsFile);
  
              List&lt;string&gt; list = doc.Root.Elements("account")
                                 .Select(element =&gt; element.Value)
                                 .ToList();
  
              this._accounts = list;
  </code></pre>