I have a XML file loaded:
XDocument xmlElements = XDocument.Parse(System.IO.File.ReadAllText(Server.MapPath("thisXml.xml")));
How do you add schema info for each "Table" data?
="1.0"="yes"
<NewDataSet>
<Table>
<Number>1</Number>
<Name>Ceres</Name>
<a>2.7681117</a>
<e>0.0757544</e>
10.59166
<N>80.3218024</N>
<w>72.73324</w>
<Pyrs>4.61</Pyrs>
<mm>0.2140072</mm>
<MA0>181.38143</MA0>
</Table>
<Table>
<Number>2</Number>
<Name>Pallas</Name>
<a>2.7723622</a>
<e>0.2310236</e>
34.84095
<N>173.0882785</N>
<w>309.98943</w>
<Pyrs>4.62</Pyrs>
<mm>0.2135153</mm>
<MA0>163.60434</MA0>
</Table>
...
</NewDataSet>
LINQ
var elements = from data in xmlElements.Descendants("//NewDataSet/Table")
select new
{
Number0 = (int)data.Element("Number"),
Name0 = (string)data.Element("Name"),
a0 = (double)data.Element("a"),
e0 = (double)data.Element("e"),
i0 = (double)data.Element("i"),
N0 = (double)data.Element("N"),
w0 = (double)data.Element("w"),
Pyrs0 = (double)data.Element("Pyrs"),
mm0 = (double)data.Element("mm"),
MA0 = (double)data.Element("MA0")
};
What I have tried:
Above needed schema INFO.
="1.0"="yes"
<NewDataSet>
<Table>
<Number>1</Number>
<Name>Ceres</Name>
<a>2.7681117</a>
<e>0.0757544</e>
10.59166
<N>80.3218024</N>
<w>72.73324</w>
<Pyrs>4.61</Pyrs>
<mm>0.2140072</mm>
<MA0>181.38143</MA0>
</Table>
<Table>
<Number>2</Number>
<Name>Pallas</Name>
<a>2.7723622</a>
<e>0.2310236</e>
34.84095
<N>173.0882785</N>
<w>309.98943</w>
<Pyrs>4.62</Pyrs>
<mm>0.2135153</mm>
<MA0>163.60434</MA0>
</Table>
...
</NewDataSet>