PDA

View Full Version : Reading xml through Qt



vikuseth
5th December 2012, 18:56
I am new to Qt and XML . Please help me on solving this . I shall be greatful to you .
Here is my XML file format


< SiteSpecific>

< SitesList>LocA;LocB;LocC< /SitesList>

< LocA>

< MaterialList>Material_A;Material_B</MaterialList>

<Material Name="Material_A">

<TemperatureList>-65;70;300;400;1000</TemperatureList>

<Density Value="0.286"/>

<PoissonRatio Value="0.27"/>

<Property tempid="01" temp="-65">
<Modulus Value="32.77E+6"/>
<Alpha Value="8.15E-6"/>
<YieldStrength Value="33.90E+3"/>
</Property>

<Property tempid="02" temp="70">
<Modulus Value="29.00E+6"/>
<Alpha Value="8.55E-6"/>
<YieldStrength Value="30.00E+3"/>
= </Property>

<Property tempid="03" temp="300">
<Modulus Value="27.50E+6"/>
<Alpha Value="9.26E-6"/>
<YieldStrength Value="22.40E+3"/>
</Property>

</Material>
</LocA>
< LocB>

< MaterialList>Material_C;Material_D</MaterialList>

<Material Name="Material_C">

<TemperatureList>-65;70;300;400;1000</TemperatureList>

<Density Value="0.286"/>

<PoissonRatio Value="0.27"/>

<Property tempid="01" temp="-65">
<Modulus Value="32.77E+6"/>
<Alpha Value="8.15E-6"/>
<YieldStrength Value="33.90E+3"/>
</Property>

<Material Name="Material_D">

<TemperatureList>-65;70;300;400;1000</TemperatureList>

<Density Value="0.286"/>

<PoissonRatio Value="0.27"/>

<Property tempid="01" temp="-65">
<Modulus Value="32.77E+6"/>
<Alpha Value="8.15E-6"/>
<YieldStrength Value="33.90E+3"/>
</Property>

</Material>
</LocB>

From the above file format i have to extract Materialist(e.g Material_A , Material_B , Material_C , Material_D) , Temperaturelist(e.g. -65,70,300,400,1000) and all the properties (Modulus , alpha and yieldstrength )based on tempid for LocA and LocB .

wysota
5th December 2012, 20:12
What is the problem you are having?

vikuseth
6th December 2012, 05:14
I am not going to read the XML file at once . The tag name will be given to the programme during runtime . Please suggest for this kind fo requirement which way i should go , QXmlStreamReader or
QDomDocument .

Please suggest some coding concept based on it ..
Thanks in adv .

wysota
6th December 2012, 10:52
Both approaches are fine. QDomDocument is easier to use for beginners, QXmlStreamReader is more versatile.