Results 1 to 4 of 4

Thread: Reading xml through Qt

  1. #1
    Join Date
    Nov 2012
    Posts
    9
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Reading xml through Qt

    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

    Qt Code:
    1. < SiteSpecific>
    2.  
    3. < SitesList>LocA;LocB;LocC< /SitesList>
    4.  
    5. < LocA>
    6.  
    7. < MaterialList>Material_A;Material_B</MaterialList>
    8.  
    9. <Material Name="Material_A">
    10.  
    11. <TemperatureList>-65;70;300;400;1000</TemperatureList>
    12.  
    13. <Density Value="0.286"/>
    14.  
    15. <PoissonRatio Value="0.27"/>
    16.  
    17. <Property tempid="01" temp="-65">
    18. <Modulus Value="32.77E+6"/>
    19. <Alpha Value="8.15E-6"/>
    20. <YieldStrength Value="33.90E+3"/>
    21. </Property>
    22.  
    23. <Property tempid="02" temp="70">
    24. <Modulus Value="29.00E+6"/>
    25. <Alpha Value="8.55E-6"/>
    26. <YieldStrength Value="30.00E+3"/>
    27. = </Property>
    28.  
    29. <Property tempid="03" temp="300">
    30. <Modulus Value="27.50E+6"/>
    31. <Alpha Value="9.26E-6"/>
    32. <YieldStrength Value="22.40E+3"/>
    33. </Property>
    34.  
    35. </Material>
    36. </LocA>
    37. < LocB>
    38.  
    39. < MaterialList>Material_C;Material_D</MaterialList>
    40.  
    41. <Material Name="Material_C">
    42.  
    43. <TemperatureList>-65;70;300;400;1000</TemperatureList>
    44.  
    45. <Density Value="0.286"/>
    46.  
    47. <PoissonRatio Value="0.27"/>
    48.  
    49. <Property tempid="01" temp="-65">
    50. <Modulus Value="32.77E+6"/>
    51. <Alpha Value="8.15E-6"/>
    52. <YieldStrength Value="33.90E+3"/>
    53. </Property>
    54.  
    55. <Material Name="Material_D">
    56.  
    57. <TemperatureList>-65;70;300;400;1000</TemperatureList>
    58.  
    59. <Density Value="0.286"/>
    60.  
    61. <PoissonRatio Value="0.27"/>
    62.  
    63. <Property tempid="01" temp="-65">
    64. <Modulus Value="32.77E+6"/>
    65. <Alpha Value="8.15E-6"/>
    66. <YieldStrength Value="33.90E+3"/>
    67. </Property>
    68.  
    69. </Material>
    70. </LocB>
    To copy to clipboard, switch view to plain text mode 

    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 .

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reading xml through Qt

    What is the problem you are having?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2012
    Posts
    9
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Reading xml through Qt

    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 .

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reading xml through Qt

    Both approaches are fine. QDomDocument is easier to use for beginners, QXmlStreamReader is more versatile.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    vikuseth (11th December 2012)

Similar Threads

  1. (Solved) Reading value from INI
    By WijbeCT in forum Newbie
    Replies: 9
    Last Post: 22nd November 2009, 05:13
  2. Reading from a QProcess
    By drhex in forum Qt Programming
    Replies: 6
    Last Post: 3rd July 2008, 17:07
  3. help in reading XML file
    By cshiva_in in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2008, 13:55
  4. reading from registry
    By phillip_Qt in forum Newbie
    Replies: 11
    Last Post: 26th October 2007, 06:49
  5. reading XML
    By joseph in forum Qt Programming
    Replies: 1
    Last Post: 22nd January 2007, 09:30

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.