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
New Developer
Posts: 12
Registered: ‎10-15-2012
My Device: Dev Alpha 10
My Carrier: MOVILNET

How I can scroll through the various levels in an XML? C++

<root>
      <header title="Frutas"> //nivel 1
           <sample name="Manzana" icon= "manzana.png"> //nivel 2
                <description text="la manzana es roja" infoText="Manzana"/> // nivel3
           </sample>
           <sample name="Cereza" icon= "cereza.png">
                <description text="la cereza es vinotinto" infoText="Cereza"/>
           </sample>
           <sample name="Pera" icon= "pera.png">
                <description text="la pera es verde" infoText="Pera" />
           </sample>
      </header>

      <header title="Vegetales"> //nivel 1
           <sample name="zanahoria" icon= "zanahoria.png"> //nivel 2
                <description text="la zanahoria es naranja" infoText="zanahoria"/> // nivel3
           </sample>
           <sample name="ajo" icon= "ajo.png">
                <description text="el ajo es blanco" infoText="ajo"/>
           </sample>
           <sample name="broccoli" icon= "brocolli.png"> 
                <description text="el broccoli es verde" infoText="brocolli" /> 
           </sample>
      </header>
</root>

 

This is my XML
I want to create a list that shows the first class I bone

frutas
vegetales

 

to just click on any of them, show me another list with the second level of each, if I press vegetales, show me a list:

zanahoria
ajo
brocolli

 

and if I press any of these items show me another screen with the third level, I mean with the description of each, if pressed zanahoria show me:

la zanahoria es naranja.

 

I have reviewed many examples, I've read the documentation and nowhere tells me how to do this, all XML examples are linear with a single level. greatly appreciate the help is urgent.

Developer
Developer
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha
My Carrier: -

Re: How I can scroll through the various levels in an XML? C++

you  can look at this KB article, it shows how to build something similar to an 'accordion'...i'm pretty sure you should be able to modify such that it works as a collapsible list (assuming that is what you were looking for)...

 

for the xml, you will need to manually parse it (i used QDomDocument,... which is built into Qt), then insert this data in the list's datamodel. for the third level, simply insert the description as an attribute that you can retrieve when you click on a ListItem.

 

in a nutshell, you have to implement:

1) your own DataModel

2) custom code to parse that XML

The rest should be easy if you went through the ListView tutorials.

Highlighted
New Developer
Posts: 12
Registered: ‎10-15-2012
My Device: Dev Alpha 10
My Carrier: MOVILNET

Re: How I can scroll through the various levels in an XML? C++

Thanks for your help, but could you give me an example of all that you say ..?
please.