Assuming you only want the subsections with a matching
ssn
, something like this should work:
from sect in XLineDoc.Descendants("section")
where (int?)sect.Attribute("lvl") == 1
let list = new LineList
{
Includes = (from ss in sect.Elements("subSec")
where (string)ss.Attribute("ssn") == "z"
from wd in ss.Elements("item")
select new LineItem
{
WdCtr = ctr++,
Word = wd.Value
}).ToList()
}
where list.Includes.Count != 0
select list;