title: C# Linq to XML - Return multiple children
body: <p>I have this xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;Interfaces&gt;
    &lt;Interface&gt;
      &lt;Name&gt;Account Lookup&lt;/Name&gt;
      &lt;PossibleResponses&gt;
        &lt;Response&gt;Account OK to process&lt;/Response&gt;
        &lt;Response&gt;Overridable restriction&lt;/Response&gt;
      &lt;/PossibleResponses&gt;
    &lt;/Interface&gt;
    &lt;Interface&gt;
      &lt;Name&gt;Balance Inquiry&lt;/Name&gt;
      &lt;PossibleResponses&gt;
        &lt;Response&gt;Funds available&lt;/Response&gt;
        &lt;Response&gt;No funds&lt;/Response&gt;
      &lt;/PossibleResponses&gt;
    &lt;/Interface&gt;
  &lt;/Interfaces&gt;
  </code></pre>
  
  <p>I need to retrieve the possible responses for an interface:</p>
  
  <pre><code>// Object was loaded with XML beforehand    
  public class Interfaces : XElement {
      public List&lt;string&gt; GetActionsForInterface(string interfaceName) {
          List&lt;string&gt; actionList = new List&lt;string&gt;();
          var actions = from i in this.Elements("Interface")
                        where i.Element("Name").Value == interfaceName
                        select i.Element("PossibleResponses").Element("Response").Value;
  
          foreach (var action in actions)
              actionList.Add(action);
  
          return actionList;
      }
  }
  </code></pre>
  
  <p>The result should be a list such as this (for interface 'Account Lookup'):<br>
  Account OK to process<br>
  Overridable restriction<br></p>
  
  <p>But its only returning the first value - 'Account OK to process'. What is wrong here?</p>
  
  <p>Edit:<br>
  I changed my method:</p>
  
  <pre><code>public List&lt;string&gt; GetActionsForInterface(string interfaceName) {
      List&lt;string&gt; actionList = new List&lt;string&gt;();
      var actions = from i in this.Elements("interface")
                    where i.Element("name").Value == interfaceName
                    select i.Element("possibleresponses").Elements("response").Select(X =&gt; X.Value);
  
      foreach (var action in actions)
          actionList.Add(action);
  
      return actionList;
  }
  </code></pre>
  
  <p>But now I get 2 errors on line 'actionList.Add(action);':</p>
  
  <pre><code>The best overloaded method match for System.Collections.Generic.List&lt;string&gt;.Add(string)' has some invalid arguments 
  Argument 1: cannot convert from 'System.Collections.Generic.IEnumerable&lt;char&gt;' to 'string'
  </code></pre>
  
  <p>I suppose the select many is casting the results into something else then strings?</p>
  
  <p>Edit:<br>
  To fix the last error:<br></p>
  
  <pre><code>    foreach (var actions in query)
          foreach(string action in actions)
              actionList.Add(action);
  </code></pre>
  
  <p>Apparently there is an array within an array here.</p>