Reputation: 23
Hi I have List of OpenXmlElement List<OpenXmlElement>
which is of Paragraphs of OpenXMLElement
and I want to get all the runs from List of Paragraphs.
List<OpenXmlElement> oFieldNodes = GetParagraphs();
// this will return first paragraph's all runs.
List<Run> oRuns = oFieldNodes[0].Descendants<Run>().ToList<Run>();
How can I get List of Runs from all the Paragraphs from oFieldNodes
using lambda expression or linq.
Any help will be appreciated. Thanks
Upvotes: 2
Views: 1474
Reputation: 12815
You can use SelectMany
List<Run> oRuns = oFieldNodes.SelectMany(o => o.Descendants<Run>()).ToList<Run>();
Upvotes: 1