Unsolved Read specific attribute in xml file
-
Hello all,
i have to read xml file and print a specific attribute name once and values in a file like
hello:Yes,No,No
hello1:No,Yes
hello3:No,No,Noi have a xml file like
<Root Name="hello" result= "yes"/>
<Root Name="hello" result= "No"/>
<Root Name="hello" result= "No"/>
<Root Name="hello1" result= "No"/>
<Root Name="hello1" result= "yes"/>
<Root Name="hello3" result= "No"/>
<Root Name="hello3" result= "No"/>
<Root Name="hello3" result= "No"/>how can i do this ? any suggestions ?
-
It depends which API you are using to read XML: Qt provides 3 ways to do it. The recommended QXmlStreamReader allows you to use QXmlStreamReader::attributes() to explorer the attributes of a StartElement.
-
@JohanSolo Thanks , i can read a attributes but i want print like this
hello:Yes,No,No
hello1:No,Yes
hello3:No,No,No
in a another file or in qdebug ?
how can i achieve this ? any idea ? -
@Narthan said:
@JohanSolo Thanks , i can read a attributes but i want print like this
in a another file or in qdebug ?
how can i achieve this ? any idea ?QDebug
is as the name suggests for debugging mostly (but clearly not only), and usually prints incerr
, therefore if you want to get the output whatever build type, rather go forcout
or a file. It's really up to you...In order to achieve the wanted counting, you have several choices: QMultiMap, a
QMap
ofQVector
, aQHash
ofQVector
, etc. Or you could use aQMap
ofQString
in which you concatenate every "result" field. -
Thank you :)