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
Regular Contributor
Sumitava_Datta
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10
My Carrier: airtel

How to sort XML data by tag attribute value in cpp using group data model,Blackberry 10 cascades?

[ Edited ]

Hi

 

I have XML file with below format..

 

<model>
    <contact id="1" name="Adam">
      <phone number="{REMOVED}" />
      <phone number="{REMOVED}" />
    </contact>
    <contact id="2" name="Annie">
      <phone number="{REMOVED}" />
      <email address="{REMOVED}" />
    </contact>
 
    <contact id="3" name="Bert">
      <phone number="{REMOVED}" />
      <phone number="{REMOVED}" />
      <phone number="{REMOVED}" />
    </contact>
</model>
 
I want to sort this XML data by "id" attribute value . Previously I sort the XML data by tag value......
 
Please help me......
 
MOD EDIT: Removed personal information to comply with Community Guidelines and Terms and Conditions of Use.
Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to sort XML data by tag attribute value in cpp using group data model,Blackberry 10 cascades?

you would have to parse the xml into a data structure and sort that, for example by using qSort or other qalgorithms
----------------------------------------------------------
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.
Regular Contributor
Sumitava_Datta
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10
My Carrier: airtel

Re: How to sort XML data by tag attribute value in cpp using group data model,Blackberry 10 cascades?

I have A XML file which contents above data . From XML file I load data in list view using group data model.

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to sort XML data by tag attribute value in cpp using group data model,Blackberry 10 cascades?

the groupdatamodel should be able to sort the items for a listview.
see https://developer.blackberry.com/cascades/reference/bb__cascades__groupdatamodel.html#property-sorti...
----------------------------------------------------------
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.
Regular Contributor
Sumitava_Datta
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10
My Carrier: airtel

Re: How to sort XML data by tag attribute value in cpp using group data model,Blackberry 10 cascades?

Hi,

 

Yes I know in group data model we can sort the data by key . I do it using tag value of a XML file but my requirement is to sort XML data by attribute value "id".

 

Please help me.....

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to sort XML data by tag attribute value in cpp using group data model,Blackberry 10 cascades?

and what stops you on using the id as a sorting key?
----------------------------------------------------------
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.
Regular Contributor
Sumitava_Datta
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10
My Carrier: airtel

Re: How to sort XML data by tag attribute value in cpp using group data model,Blackberry 10 cascades?

How to write attribute name as a sorting key in .cpp file.Can you tell me ?

 

Please help me....

Please use plain text.