Is there a way to read XML file into a list but not create a list inside of a list when only having one element.
<DewesoftSetup>
<Devices>
<StartStoreTime>43874.6969328704</StartStoreTime>
<SampleRate>50000</SampleRate>
<BlockSize>1000</BlockSize>
<Device Type="AI">
<Slot Index="0">
<MeasuredValue>VOLTAGE</MeasuredValue>
<Range>10 V</Range>
<LPFilter_Type>BU</LPFilter_Type>
<LPFilter_Hz>10000</LPFilter_Hz>
<LPFilter_Order>2</LPFilter_Order>
<AmplifierChainInfo>
<AmplifierInfo Index="0" Type="DEWEUSB_AMPLIFIER">
<Name>SIRIUS-HD-ACC</Name>
<SerialNr>D013C47522</SerialNr>
<Revision>1.3.0.0</Revision>
<Firmware>1.10</Firmware>
<CalDate>09.01.2020</CalDate>
<Measurement>Voltage</Measurement>
<Range>10 V</Range>
<LP_filter>10 kHz* (HW: 100 kHz)</LP_filter>
<LP_filter_type>Butterworth*</LP_filter_type>
<LP_filter_order>2nd*</LP_filter_order>
<HP_filter>AC 1 Hz (SW: 0.1 Hz)</HP_filter>
</AmplifierInfo>
</AmplifierChainInfo>
</Slot>
</Devices>
</DewesoftSetup>
I only have one Amplifier per slot. I am making a list based on the slots but the only way I know how to get the data from ````` is to create another list.
var devices = from y in xdoc.Descendants("DewesoftSetup").Descendants("Device").Where(e => e.Attribute("Type").Value == "AI").Descendants("Slot")
select new DewesoftDevices
{
slotNum = y.Attribute("Index").Value,
measuredValue = y.Element("MeasuredValue").Value,
range = y.Element("Range").Value,
lpFilterType = y.Element("LPFilter_Type").Value,
lpFilter = y.Element("LPFilter_Hz").Value,
lpFilterOrder = y.Element("LPFilter_Order").Value,
dewesoftAmplifier = new DewesoftAmplifier()
{
ampInfo = new List<AmplifierInfo>(from ampOutput in y.Descendants("AmplifierChainInfo").Descendants("AmplifierInfo")
select new AmplifierInfo
{
type = ampOutput.Attribute("Type").Value,
name = ampOutput.Element("Name").Value,
cardSerialNumber = ampOutput.Element("SerialNr").Value,
revision = ampOutput.Element("Revision").Value,
calDate = ampOutput.Element("CalDate").Value,
range = ampOutput.Element("Range").Value,
lpFilter = ampOutput.Element("LP_filter").Value,
lpFilterType = ampOutput.Element("LP_filter_type").Value,
lpFilterOrder = ampOutput.Element("LP_filter_order").Value,
hpFilter = ampOutput.Element("HP_filter").Value
})
}
Is there a way to just create one instance in each slot instead of creating another list int each slot?