I'm writing a programm which need to read xml data, but i can't understand how to do it.
I know how to bind it to xaml but i don't need that. Elements not static, change their values and some of them are showing after some moves. And i need readin the xml in mvvm model because it's only one element of the programm.
Here's the short ver of xml:
<Stores>
<Tank Name="Side fresh water tank No.1 SB" Weight="0.00" SG="1.000" VolumeMax="144.01">
<DepartureTable>
<Volume Level="0.00" Value="0.00" X="-29.30" Y="8.10" Z="1.30" SFS="0.00" SFX="0.00" SFY="0.00" SFIX="0.00" SFIY="0.00"/>
<Volume Level="0.10" Value="1.35" X="-29.65" Y="8.07" Z="1.35" SFS="13.90" SFX="-29.50" SFY="8.10" SFIX="8.30" SFIY="378.00"/>
<Volume Level="0.20" Value="2.78" X="-29.71" Y="8.07" Z="1.40" SFS="14.60" SFX="-29.70" SFY="8.10" SFIX="8.70" SFIY="396.00"/>
<Volume Level="0.30" Value="4.28" X="-29.77" Y="8.07" Z="1.45" SFS="15.30" SFX="-29.80" SFY="8.10" SFIX="9.10" SFIY="413.00"/>
</Tank>
</Stores>
The idea next. No buttons. Only two datagrids. first have 4 columns where name, weight, sg, volume. weight and volume are 0 and weight = sg * volume, volume = weight / sg. after changing one of three (sg too) values check (volume != 0) and if yes: Show on the secind datagrid name, volume, x, y, z, volumex, volumey, volume*z.
if i use something like this what is my next step?
public class StoresModel
{
private StoresModel()
{
XmlDocument xml = new XmlDocument();
xml.Load("Tanks.xml");
}
[XmlRoot("Stores")]
public class StoresCollection
{
[XmlElement("Tank")]
public Tank[] Tanks { get; set; }
}
public class Tank
{
[XmlAttribute("Name")]
public string Name { get; set; }
[XmlAttribute("Weight")]
public string Weight { get; set; }
[XmlAttribute("SG")]
public string SG { get; set; }
[XmlAttribute("VolumeMax")]
public string VolumeMax { get; set; }
[XmlArray("DepartureTable")]
[XmlArrayItem("Volume", typeof(DepartureVolume))]
public DepartureVolume[] Volumes { get; set; }
}
public class DepartureVolume
{
[XmlAttribute("Level")]
public double Level { get; set; }
[XmlAttribute("Value")]
public double Value { get; set; }
[XmlAttribute("X")]
public double X { get; set; }
[XmlAttribute("Y")]
public double Y { get; set; }
[XmlAttribute("Z")]
public double Z { get; set; }
[XmlAttribute("SFS")]
public double SFS { get; set; }
[XmlAttribute("SFX")]
public double SFX { get; set; }
[XmlAttribute("SFY")]
public double SFY { get; set; }
[XmlAttribute("SFIX")]
public double SFIX { get; set; }
[XmlAttribute("SFIY")]
public double SGIY { get; set; }
}
}