title: Generically Flatten XDocument using Linq?
body: <p>There is a <a href="https://stackoverflow.com/questions/8900089/can-i-flatten-an-xdocument-with-linq">question</a> that does almost exactly what I want to do by almost the same name, however I don't know what my XML DOM will look like ahead of time.</p>
  
  <p>I would like to do something like this:</p>
  
  <pre><code>private static IEnumerable&lt;XElement&gt; FindAllContainers(XDocument xml)
  {
            IEnumerable&lt;XElement&gt; query = from XElement outer in xml.Root.Elements()
                                          from XElement node in outer.Elements()
                                          where true //Enum.IsDefined(typeof(Role), GetContainerRole(node)) 
                                          select node;
                                          return query;
  }
  </code></pre>
  
  <p>The basic Idea is I want to query against an enumeration of <em>all</em> XElements for any given XML structure. The above code doesn't return any results. With xml containing a large nested XML structure and being an XDocument. The other question manually supplies Elements with the tag names. I don't know what they are ahead of time to set it up statically in the method.</p>