You're not using the
System.Xml.Linq
namespace. Here is the official documentation:
How to find descendant elements - LINQ to XML | Microsoft Learn[
^]
This is an example based on the documentation link above:
using System.Xml.Linq;
XDocument xDoc = XDocument.Load(Path.Combine(Environment.CurrentDirectory, @".\xml\VSOP87-J2000.xml"));
var elements = xDoc.Root.Descendants("VSOP87-J2000");
foreach (XElement el in elements)
{
Console.WriteLine(el.Name);
if (el.HasElements)
{
foreach (var subEl in el.Descendants())
{
Console.WriteLine($" {subEl.Name} = {subEl.Value}");
}
}
}
And here is the output:
VSOP87-J2000
ID = 1
A5sun = 0.00000006867
B5sun = 4.39735582882
C5sun = 117.3198682202
VSOP87-J2000
ID = 2
A5sun = 0.00000007226
B5sun = 4.04267257839
C5sun = 1265.5674786264
This should be enough to point you in the right direction.