I have the following XML, and I'm trying to get into an array using LINQ:
<doc>
<rows>
<cols>
<a>value</a>
<b>value</b>
<c>value</c>
<d>value</d>
</cols>
// multiple col elements
</rows>
// multiple rows elements, each has a set of col elements
</doc>
// single doc (root) element
using this code:
ObjectType[][] var = (
from e in XDocument.Load("Test.xml").Root.Elements()
select (
from cols in e.Elements("cols")
select new ObjectType
{
a = (int)e.Element("a"),
b = (int)e.Element("b"),
c = (int)e.Element("c"),
d = (int)e.Element("d")
}).ToArray()).ToArray();
Where ObjectType is a simple structure of ints: a, b, c, and d. The XML looks properly-formatted, but I keep getting System.ArgumentNullException. From what I can make out in the debugger, it doesn't get past the first element.
How is my brain failing me on this one?