Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Read XML files and select info
Forum Updated to NodeBB v4.3 + New Features

Read XML files and select info

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 515 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MirreCap
    wrote on last edited by MirreCap
    #1

    Hello everyone,
    I am currently developing a project in my master's thesis and need some help. I'm new to Qt Creator 4.8.2 and XML files and so I'm still trying to understand how it works. Right now I have a problem that I can not solve. I'm working with QXmlSimpleReader Class to read this xml file:

    <?xml version="1.0" encoding="UTF-8"?>
    <hdevelop file_version="1.2" halcon_version="18.11.1.1">
    <procedure name="clips_orientation">
    <interface>
    <oo>
    <par name="Clips" base_type="iconic" dimension="0"/>
    <par name="Regions" base_type="iconic" dimension="0"/>
    <par name="ConnectedRegions" base_type="iconic" dimension="0"/>
    <par name="SelectedRegions" base_type="iconic" dimension="0"/>
    </oo>
    <oc>
    <par name="Phi" base_type="ctrl" dimension="0"/>
    <par name="Area" base_type="ctrl" dimension="0"/>
    <par name="Row" base_type="ctrl" dimension="0"/>
    <par name="Column" base_type="ctrl" dimension="0"/>
    </oc>
    </interface>
    <body>
    <l>read_image (Clips, clips.png')</l>
    <l>draw_circle (WindowHandle, Row1, Column1, Radius)</l>
    <l>gen_circle (Circle, Row1, Column1, Radius)</l>
    <l>reduce_domain (Clips, Circle, ImageReduced)</l>
    <l>threshold (ImageReduced, Regions, 3, 60)</l>
    <l>connection (Regions, ConnectedRegions)</l>
    <l>select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 4500, 6300)</l>
    <l>orientation_region (SelectedRegions, Phi)</l>
    <l>area_center (SelectedRegions, Area, Row, Column)</l>
    <l>return ()</l>
    </body>
    <docu id="clips_orientation">
    <parameters>
    <parameter id="Area"/>
    <parameter id="Clips"/>
    <parameter id="Column"/>
    <parameter id="ConnectedRegions"/>
    <parameter id="Phi"/>
    <parameter id="Regions"/>
    <parameter id="Row"/>
    <parameter id="SelectedRegions"/>
    </parameters>
    </docu>
    </procedure>
    </hdevelop>
    

    I need to read the file and return:

    • All <parameter id=> of the <parameters>-> Area, Clips, Column, ConnectedRegions, Phi, Regions, Row, SelectedRegions
    • The first word of each line of the <body>-> read_image, draw_circle, gen_circle, reduce_domain, threshold, connection, select_shape, orientation_region and area_center.
      From now on thank you very much to who can pay attention to my problem and continuation of good programming.
      Best regards, Miguel
    JonBJ 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @MirreCap said in Read XML files and select info:

      QXmlSimpleReader

      Hi
      they show how to use it here
      http://www.informit.com/articles/article.aspx?p=1405553&seqNum=3

      Basically, you subclass QXmlDefaultHandler and fill out the parsing handlers.

      1 Reply Last reply
      2
      • M MirreCap

        Hello everyone,
        I am currently developing a project in my master's thesis and need some help. I'm new to Qt Creator 4.8.2 and XML files and so I'm still trying to understand how it works. Right now I have a problem that I can not solve. I'm working with QXmlSimpleReader Class to read this xml file:

        <?xml version="1.0" encoding="UTF-8"?>
        <hdevelop file_version="1.2" halcon_version="18.11.1.1">
        <procedure name="clips_orientation">
        <interface>
        <oo>
        <par name="Clips" base_type="iconic" dimension="0"/>
        <par name="Regions" base_type="iconic" dimension="0"/>
        <par name="ConnectedRegions" base_type="iconic" dimension="0"/>
        <par name="SelectedRegions" base_type="iconic" dimension="0"/>
        </oo>
        <oc>
        <par name="Phi" base_type="ctrl" dimension="0"/>
        <par name="Area" base_type="ctrl" dimension="0"/>
        <par name="Row" base_type="ctrl" dimension="0"/>
        <par name="Column" base_type="ctrl" dimension="0"/>
        </oc>
        </interface>
        <body>
        <l>read_image (Clips, clips.png')</l>
        <l>draw_circle (WindowHandle, Row1, Column1, Radius)</l>
        <l>gen_circle (Circle, Row1, Column1, Radius)</l>
        <l>reduce_domain (Clips, Circle, ImageReduced)</l>
        <l>threshold (ImageReduced, Regions, 3, 60)</l>
        <l>connection (Regions, ConnectedRegions)</l>
        <l>select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 4500, 6300)</l>
        <l>orientation_region (SelectedRegions, Phi)</l>
        <l>area_center (SelectedRegions, Area, Row, Column)</l>
        <l>return ()</l>
        </body>
        <docu id="clips_orientation">
        <parameters>
        <parameter id="Area"/>
        <parameter id="Clips"/>
        <parameter id="Column"/>
        <parameter id="ConnectedRegions"/>
        <parameter id="Phi"/>
        <parameter id="Regions"/>
        <parameter id="Row"/>
        <parameter id="SelectedRegions"/>
        </parameters>
        </docu>
        </procedure>
        </hdevelop>
        

        I need to read the file and return:

        • All <parameter id=> of the <parameters>-> Area, Clips, Column, ConnectedRegions, Phi, Regions, Row, SelectedRegions
        • The first word of each line of the <body>-> read_image, draw_circle, gen_circle, reduce_domain, threshold, connection, select_shape, orientation_region and area_center.
          From now on thank you very much to who can pay attention to my problem and continuation of good programming.
          Best regards, Miguel
        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by JonB
        #3

        @MirreCap
        For your choice of QXmlSimpleReader, are you wedded to it, I'll just point out https://doc.qt.io/qt-5/qxmlstreamreader.html#details:

        QXmlStreamReader is a faster and more convenient replacement for Qt's own SAX parser (see QXmlSimpleReader).

        QXmlSimpleReader uses the event/callback-driven approach to parsing, which is "cumbersome" for your own code. If you can, do yourself a favour and at least move to the more convenient QXmlStreamReader.

        Using QDomDocument + XQuery/QXmlQuery is even easier, but I have a feeling I have seen this/these are "no longer maintained" and you're supposed to use QXmlStreamReader. Which is a shame/backward step for those of us who like XML.

        http://3gfp.com/wp/2014/07/three-ways-to-parse-xml-in-qt/ compares these 3 approaches.

        1 Reply Last reply
        3

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved