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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Regular Contributor
Sanjit_Patra
Posts: 72
Registered: ‎01-08-2013
My Carrier: Airtel

XML parsing

Hi All,

 

  I am new to BB10 Development.

 

I have made connection with my server which is sending data in JSON Format. How to parse it.  Can anyone help me with this.It will be very helpful for me.

Also how to store the parsed data in database or ArrayList. 

 

Thanks & Regards

    Sanjit

Please use plain text.
Developer
simon_hain
Posts: 14,051
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: XML parsing

check the samples, there is one for JSON afaik.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
velkin
Posts: 33
Registered: ‎10-28-2012
My Carrier: Rogers

Re: XML parsing

Not sure if you want XML parsing or JSON parsing, since your title is XML and you're talking about JSON. They are different.

 

You can parse XML this way:

 

 

 

QDomDocument xmlDoc;
QString parseError;
int errorLine = 0;
int errorCol = 0;
xmlDoc.setContent ( response, &parseError, &errorLine, &errorCol);

 

if (errorLine == 0 && errorCol == 0){
             QDomNodeList nodes = xmlDoc.elementsByTagName ( "nodeName" );
             if (nodes.length() > 0){

                 QDomNode node = nodes.item(0);
                 QDomElement element = node.toElement();
                 QString stringVal = element.text().trimmed();
        }
}

 

 

Here are example projects for JSON and XML:

 

https://github.com/blackberry/Cascades-Samples/tree/master/jsonreadwrite

https://github.com/blackberry/Cascades-Samples/tree/master/stampcollector

 

 

 

 

*Like or mark as solution!*
Please use plain text.