Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 19
Registered: ‎03-06-2014
My Device: blackberry z10 stl100-3
My Carrier: n/a

Extracting QVariantMap data pairs

I have a giant xml file I converted into a QVariantMap:

 

QMap((".root", QVariant(QString, "UpdateApp_Response") )

( "AppCashSign" ,  QVariant(QString, "false") )

( "AppCashTrans" ,  QVariant(QString, "false") )...

 

when I output it to the console it gets cut off before it reaches the good part:

 

<MerchFooter>Thank You For Visiting Us.</MerchFooter>
<AppLanguage>
    <_AppLanguage>
        <LanguageID>1</LanguageID>
        <LanguageValue>Enter Activation Codes</LanguageValue>
    </_AppLanguage>

 

I need to extract the LanguageValue associated with the LanguageID

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Extracting QVariantMap data pairs

There's limits on what the console prints out for line length and content.

 

Why not just write a quick for loop and check it that way?


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 19
Registered: ‎03-06-2014
My Device: blackberry z10 stl100-3
My Carrier: n/a

Re: Extracting QVariantMap data pairs

good idea, I used this to go through it:

 

for(QVariantMap::const_iterator iter = data.begin(); iter != data.end(); ++iter) {
        qDebug() << iter.key() << iter.value();
}

 

it spat out values like so until it hit the sub Qmap, the place I want the data&colon;

"randomstuff" QVariant(QString, "false")
"morerandomstuff" QVariant(QString, "false")
"morerandomstuff" QVariant(QString, "false")

.....

"MoreStuff" QVariant(QVariantMap, QMap(
("_MoreStuff", QVariant(QVariantList, (QVariant(QVariantMap, QMap(
("stuffID", QVariant(QString, "1") )
( "stuffValue" , QVariant(QString, "I want this value 1") ))) ,
QVariant(QVariantMap, QMap(("stuffID", QVariant(QString, "2") )
( "stuffValue" , QVariant(QString, "I want this value 2") ) ) ) ,
QVariant(QVariantMap, QMap(("stuffID", QVariant(QString, "3") )
( "stuffValue" , QVariant(QString, "I want this value 3...

 

so I basically want to search for stuffID "1" and get the associated stuffValue "I want this value 1"

Developer
Posts: 19
Registered: ‎03-06-2014
My Device: blackberry z10 stl100-3
My Carrier: n/a

Re: Extracting QVariantMap data pairs

[ Edited ]

I simplified the QVariantMap to this:

 

QMap(
	("_MoreStuff", QVariant
		(QVariantList, 
			(QVariant
				(QVariantMap, QMap
					(("stuffID", QVariant(QString, "1") ) 
					( "stuffValue" ,  QVariant(QString, "I want this value 1") ) )
				) ,   
			QVariant
				(QVariantMap, QMap
					(("stuffID", QVariant(QString, "2") ) 
					( "stuffValue" ,  QVariant(QString, "I want this value 2") ) )
				) ,  
			QVariant(
				QVariantMap, QMap
					(("stuffID", QVariant(QString, "3") ) 
					( "stuffValue" ,  QVariant(QString, "I want this value 3") ) )  
				) ...

 I want to search for stuffID of value 2 for instance and get the associated stuffValue of "I want this value 2"

Anyone know how to do this, or point me in the direction of helpful documentation?