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
Contributor
MaddinBB
Posts: 10
Registered: ‎02-25-2013
My Device: Simulator
Accepted Solution

Retrieve data from xml file

Hi,

 

Consider, having following xml file

 

<model>
	<header title="A">
		<city title="Algiers">
			<lonlat value="36.76,3.05" />
		</city>
        </header>
</model>

 How can I retrieve the value from the lonlat key "36.76,3.05"

 

in my qml file I got something like

 

...
        Page {
            id: ch_loc
            Container {

                //background: Color.White
                ListView {
                    dataModel: XmlDataModel {
                        source: "LonLat.xml"
                    }
                    listItemComponents: [
                        ListItemComponent {
                        }
                    ]
                    onTriggered: {
                        //qDebug(indexPath[3]);
                        app.initiateRequest(dataModel.data(indexPath[0]))
                    }
                }
            }
        }
...

 Am I on the right way? Need help please.

 

Thank you, regards.

 

Maddin

Contributor
MaddinBB
Posts: 10
Registered: ‎02-25-2013
My Device: Simulator

Re: Retrieve data from xml file

I've found this documentation:
http://developer.blackberry.com/cascades/documentation/ui/lists/list_view_selection.html
I think that this is exactly what I need.
Contributor
MaddinBB
Posts: 10
Registered: ‎02-25-2013
My Device: Simulator

Re: Retrieve data from xml file

Hi,

 

Ok after some reading, I figured it out.

 

What I did:

 

Page {
            id: ch_loc
            Container {

                //background: Color.White
                ListView {
                    dataModel: XmlDataModel {
                        source: "LonLat.xml"
                    }
                    listItemComponents: [
                        ListItemComponent {
                        }
                    ]
                    onTriggered: {
                        var selectedItem = dataModel.data(indexPath);
                        app.initiateRequest(selectedItem.value);
                    }
                }
            }
        }

Please dont understand it wrong. Iam not asking to get help without doing anything by myself. Iam new to this and iam struggling to understand the whole material. For now iam happy, that i've understood this part.

So this is done for me.

Regards

Maddin

Contributor
MaddinBB
Posts: 10
Registered: ‎02-25-2013
My Device: Simulator

Re: Retrieve data from xml file

Hi,

 

For those who are interessted how the xml file looks like, at the moment:

 

<model>
        <header title="A">
		<city title="Algiers" value="36.76,3.05" />
		<city title="Andorra la Vella" value="42.48,1.50" />
                ...
        </header>
        ...
</model>

Regards,

Maddin