Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

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

    General and Desktop
    xml qxml qxmlstreamreade
    3
    4
    399
    Loading More Posts
    • 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.
    • Ripley
      Ripley last edited by 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>
      
      JonB 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @Ripley last edited by JonB

        @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 Reply Quote 1
        • mrjj
          mrjj Lifetime Qt Champion last edited by

          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 Reply Quote 3
          • Ripley
            Ripley last edited by

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

            1 Reply Last reply Reply Quote 1
            • First post
              Last post