How Can I Get a List<int> From Linq to XML that Produces List<List<int>>?
- by DaveDev
I have an XML snippet as follows:
<PerformancePanel>
<LegalText>
<Line id="300" />
<Line id="304" />
<Line id="278" />
</LegalText>
</PerformancePanel>
I'm using the following code to get an object:
var performancePanels = new
{
Panels = (from panel in doc.Elements("PerformancePanel")
select new
{
LegalTextIds = (from legalText in panel.Elements("LegalText").Elements("Line")
select new List<int>()
{
(int)legalText.Attribute("id")
}).ToList()
}).ToList()
};
The type of LegalTextIds is List<List<int>>. How can I get this as a List<int>?