I am trying to read an XML file which is generated by Matlab (a XML representation of Simulink Model). For the sake of question I have shortened it. Below is the XML.
<?xml version="1.0" encoding="utf-8"?>
<ModelInformation Version="1.0">
<Model Name="MatlabToJenkinsIntegrationSample">
<P Name="Version">9.0</P>
<P Name="SavedCharacterEncoding">windows-1252</P>
<GraphicalInterface>
<P Name="NumRootInports">3</P>
<Inport Name="Input1">
<P Name="BusObject"/>
<P Name="OutputFunctionCall">off</P>
<P Name="SampleTime">-1</P>
<P Name="UnitExpr">inherit</P>
</Inport>
<Inport Name="Input2 ">
<P Name="BusObject"/>
<P Name="OutputFunctionCall">off</P>
<P Name="SampleTime">-1</P>
<P Name="UnitExpr">inherit</P>
</Inport>
<Inport Name="MultiplicationFactor">
<P Name="BusObject"/>
<P Name="OutputFunctionCall">off</P>
<P Name="SampleTime">-1</P>
<P Name="UnitExpr">inherit</P>
</Inport>
<P Name="NumRootOutports">1</P>
<Outport Name="Result">
<P Name="BusObject"/>
<P Name="BusOutputAsStruct">off</P>
<P Name="UnitExpr">inherit</P>
</Outport>
<P Name="ParameterArgumentNames"/>
<P Name="ComputedModelVersion">1.4</P>
<P Name="NumModelReferences">0</P>
<P Name="NumTestPointedSignals">0</P>
</GraphicalInterface>
</Model>
</ModelInformation>
I had a look at it and it gave a clear Class and it's properties(for me). So I generated the classes as shown below
public class Model
{
public string Name { get; set; }
public string Version { get; set; }
public string SavedCharacterEncoding { get; set; }
public GraphicalInterface TheGraphicalInterface { get; set; }
}
public class GraphicalInterface
{
public List<InPort> InPorts { get; set; }
public List<OutPort> OutPorts { get; set; }
}
And Similarly for InPort
and OutPort
.
Now the question is that how do I parse it into these classes. I can not wrap my head around it. Creating classes looks logical but after that I am not able to progress at all.
Please provide the input and a solution. There are no values as there in normal XML file. I have looked at certain examples but not able to find a solution.