How to read whole child into a parent tag in xml?
-
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>
-
@Ripley
https://doc.qt.io/qt-5/qxmlstreamreader.html#attributes gives you aQXmlStreamAttributes
, aQVector
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 yourQXmlStreamWriter
. -
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.