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: 10
Registered: ‎04-24-2014
My Device: Z10
My Carrier: Airtel

Parsing data from the fields in a form to a XML file

I am able to print the data from a XML file to my listview but i am not able to add new entries through the form which i created

Developer
Posts: 47
Registered: ‎11-23-2010
My Device: Q10
My Carrier: Rogers

Re: Parsing data from the fields in a form to a XML file

It would be better if you provide some source code. Thanks.

New Developer
Posts: 10
Registered: ‎04-24-2014
My Device: Z10
My Carrier: Airtel

Re: Parsing data from the fields in a form to a XML file

Container {

                    

                    layout: StackLayout {

                        orientation: LayoutOrientation.LeftToRight

                    

                    }

                    layoutProperties: StackLayoutProperties {

                        spaceQuota: 4.0

                    

                    }

                    Label {

 

                        text: "Name of Medicine"

                        verticalAlignment: VerticalAlignment.Center

 

                    }

                    TextField {

                        id: medname

                        preferredWidth: 400.0

                        verticalAlignment: VerticalAlignment.Center

                        horizontalAlignment: HorizontalAlignment.Right

 

                    }

 

                }

                Divider {

 

                }

                Container {

                    layout: StackLayout {

                        orientation: LayoutOrientation.LeftToRight

 

                    }

                    layoutProperties: StackLayoutProperties {

                        spaceQuota: 4.0

 

                    }

                    Label {

                        text: "Dosage"

                        verticalAlignment: VerticalAlignment.Center

 

                    }

                    TextField {

                        id: dosage

                        preferredWidth: 300.0

                        verticalAlignment: VerticalAlignment.Center

                        horizontalAlignment: HorizontalAlignment.Right

                        

 

                    }

 

                }

                Divider {

 

                }

                Container {

                    layout: StackLayout {

                        orientation: LayoutOrientation.LeftToRight

 

                    }

                    layoutProperties: StackLayoutProperties {

                        spaceQuota: 4.0

 

                    }

                    Label {

                        text: "Form of medicine"

                        verticalAlignment: VerticalAlignment.Center

 

                    }

                    DropDown {

                        id: dd

                        preferredWidth: 400.0

                        verticalAlignment: VerticalAlignment.Center

                        horizontalAlignment: HorizontalAlignment.Right

                        Option {

                            text: "Tablet"

                            value:"Tablet"

 

                        }

                       

                        Option {

                            text: "Spoon"

                            value: "Spoon"

 

                        }

 

                    }

 

                }

                Divider {

 

                }

                Container {

                    layoutProperties: StackLayoutProperties {

                        spaceQuota: 4.0

 

                    }

                    layout: StackLayout {

                        orientation: LayoutOrientation.LeftToRight

 

                    }

                    Label {

                        text: "Time"

                        verticalAlignment: VerticalAlignment.Center

 

                    }

                    DateTimePicker {

                        id: dpicker

 

                        mode: DateTimePickerMode.DateTime

                        verticalAlignment: VerticalAlignment.Center

                        preferredWidth: 500.0

                        horizontalAlignment: HorizontalAlignment.Right

 

                    }

 

                }

                Divider {

 

                }

                Container {

                    layoutProperties: StackLayoutProperties {

                        spaceQuota: 4.0

 

                    }

                    layout: StackLayout {

                        orientation: LayoutOrientation.LeftToRight

 

                    }

                    Button {

                        text: "Add"

                        verticalAlignment: VerticalAlignment.Center

                        horizontalAlignment: HorizontalAlignment.Left

                        leftMargin: 20.0

                        layoutProperties: StackLayoutProperties {

                            spaceQuota: 2.0

 

                        }

                        onClicked: {

                            notification.notify();

                            notificationd.show();

                        }

 

                    }

                    

I want to store the input from all the text fileds, dropdown and timepicker to a xml file

Developer
Posts: 47
Registered: ‎11-23-2010
My Device: Q10
My Carrier: Rogers

Re: Parsing data from the fields in a form to a XML file

Well data collection from all fields is missing in OnClicked slot. The file opening and saving fields in XML format is missing too. I don't know if this is all you have or something you didn't post.

 

Anyway, one of solutions is :

 

 

1. Create CPP class with XML write method and lets say QString members whos gonna hold values to write into XML.

2. Create object of this class and expose it to QML (the one you provided)

3. In OnClicked() method: set all members from exposed object to values from text fields in the form.

4. Call the "write to XML" method of the object so it will output everything into file.

 

New Developer
Posts: 10
Registered: ‎04-24-2014
My Device: Z10
My Carrier: Airtel

Re: Parsing data from the fields in a form to a XML file

Are there any sample apps for the same??
Retired
Posts: 252
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: Parsing data from the fields in a form to a XML file

Hi veerdhwaj,

 

To save your XML data, you need to use the XmlDataAccess class:

https://developer.blackberry.com/native/reference/cascades/bb__data__xmldataaccess.html

 

There is currently no sample app demoing the use of this class, but you can check how its Json counterpart works in the jsonreadwrite sample app available on Github, which works in a very close fashion:

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

@SamarAbdelsayed

Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker