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. How to read whole child into a parent tag in xml?
QtWS25 Last Chance

How to read whole child into a parent tag in xml?

Scheduled Pinned Locked Moved Solved General and Desktop
xmlqxmlqxmlstreamreade
4 Posts 3 Posters 865 Views
  • 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.
  • R Offline
    R Offline
    Ripley
    wrote on 4 Jul 2019, 14:39 last edited by Ripley 7 Apr 2019, 14:47
    #1

    Hello guys. I got a little question.

    My problem is what kind of algorithm could use to take the child-items' xml of its parent tag. I don't know how go through the xml text to arrive from the parent by id to the their child, the main goal is take the attributes of the child by each parent it's all that I want. Thanks.

    Note => It's necessary to use libraries like QXmlStreamReader

    <?xml version='1.0' encoding='UTF-8'?> 
    <parent code="350" id="1" name="Arquitectura">
        <child cd="0" description="Estructuras metalicas" dib="0" ia="0" ib="0" ic="0" ings="0" jp="0" ld="0" name="19111-340-LE-001" pac="0" pr="0" quality="0" />
       <child cd="0" description="Estructuras metalicas" dib="0" ia="0" ib="0" ic="0" ings="0" jp="0" ld="0" name="19111-340-LE-001" pac="0" pr="0" quality="0" />
    </parent>
    
    J 1 Reply Last reply 4 Jul 2019, 14:51
    0
    • R Ripley
      4 Jul 2019, 14:39

      Hello guys. I got a little question.

      My problem is what kind of algorithm could use to take the child-items' xml of its parent tag. I don't know how go through the xml text to arrive from the parent by id to the their child, the main goal is take the attributes of the child by each parent it's all that I want. Thanks.

      Note => It's necessary to use libraries like QXmlStreamReader

      <?xml version='1.0' encoding='UTF-8'?> 
      <parent code="350" id="1" name="Arquitectura">
          <child cd="0" description="Estructuras metalicas" dib="0" ia="0" ib="0" ic="0" ings="0" jp="0" ld="0" name="19111-340-LE-001" pac="0" pr="0" quality="0" />
         <child cd="0" description="Estructuras metalicas" dib="0" ia="0" ib="0" ic="0" ings="0" jp="0" ld="0" name="19111-340-LE-001" pac="0" pr="0" quality="0" />
      </parent>
      
      J Offline
      J Offline
      JonB
      wrote on 4 Jul 2019, 14:51 last edited by JonB 7 Apr 2019, 14:51
      #2

      @Ripley
      https://doc.qt.io/qt-5/qxmlstreamreader.html#attributes gives you a QXmlStreamAttributes, a QVector of all the attributes of an element. I'm not totally sure what you're trying to do which way round, but you can use that to read, and https://doc.qt.io/qt-5/qxmlstreamwriter.html#writeAttribute-2 to write/add an attribute to your QXmlStreamWriter.

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 4 Jul 2019, 14:52 last edited by
        #3

        Hi
        Something like shown here
        https://www.walletfox.com/course/qxmlstreamreaderexample.php
        and when in the "child" node, use
        QXmlStreamReader::attributes() to get the attributes.

        1 Reply Last reply
        3
        • R Offline
          R Offline
          Ripley
          wrote on 4 Jul 2019, 16:16 last edited by
          #4

          @mrjj Hey bro thanks a lot that article was help me a lot to solve it.

          1 Reply Last reply
          1

          4/4

          4 Jul 2019, 16:16

          • Login

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