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?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
xmlqxmlqxmlstreamreade
4 Posts 3 Posters 900 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.
  • RipleyR Offline
    RipleyR Offline
    Ripley
    wrote on last edited by Ripley
    #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>
    
    JonBJ 1 Reply Last reply
    0
    • RipleyR Ripley

      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>
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #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
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on 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
        • RipleyR Offline
          RipleyR Offline
          Ripley
          wrote on 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

          • Login

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