Generically Flatten XDocument using Linq?
There is a [question][1] 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.

I would like to do something like this:

    private static IEnumerable<XElement> FindAllContainers(XDocument xml)
    {
              IEnumerable<XElement> 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;
    }


The basic Idea is I want to query against an enumeration of *all* 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.

  [1]: http://stackoverflow.com/questions/8900089/can-i-flatten-an-xdocument-with-linq
Generically Flatten XDocument using Linq?
===

There is a [question][1] 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.

I would like to do something like this:

    private static IEnumerable<XElement> FindAllContainers(XDocument xml)
    {
              IEnumerable<XElement> 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;
    }


The basic Idea is I want to query against an enumeration of *all* 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.

  [1]: http://stackoverflow.com/questions/8900089/can-i-flatten-an-xdocument-with-linq