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
Super Contributor
JeffLemon
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
My Carrier: NA

Create an XML file?

I need to dynamically create an xml file from my app.

 

Can someone point me in the right direction?

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Please use plain text.
Developer
Zmey
Posts: 1,511
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Create an XML file?

Hi,

 

This can be done with QXmlStreamWriter. This page also has sample usage:

http://doc.qt.digia.com/stable/qxmlstreamwriter.html

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Trusted Contributor
Sith_Apprentice
Posts: 207
Registered: ‎05-02-2010
My Device: various
My Carrier: AT&T

Re: Create an XML file?

Also check here

 

https://developer.blackberry.com/cascades/documentation/device_platform/data_access/working_with_xml...

If you are the original poster (OP) and your issue is solved, please remember to click the "Accept as Solution" button so that others can more easily find it. If anyone has been helpful to you, please show your appreciation by clicking the Star on the left of their post.
Please use plain text.
New Developer
Watman
Posts: 15
Registered: ‎02-12-2013
My Device: Bold 9900 - Z10 LE - DAC - Playbook

Re: Create an XML file?

I presume/think there might be an error on that page.

On the topic of saving the XML, they show following sampleCode:

 

// Add the employee list to a top-level QVariantMap, then wrap it in a QVariant
QVariantMap topLevelEmployeeMap;
myData[".root"] = QVariant("employees");
myData["employee"] = QVariant(myEmployeeList);
QVariant myData = QVariant(topLevelEmployeeMap);
 
You will be getting a compiler error on the second line because "myData was not declared' ==> typo?
Should this be:
// Add the employee list to a top-level QVariantMap, then wrap it in a QVariant
QVariantMap topLevelEmployeeMap;
topLevelEmployeeMap[".root"] = QVariant("employees");
topLevelEmployeeMap["employee"] = QVariant(myEmployeeList);
QVariant myData = QVariant(topLevelEmployeeMap);
---------------------------------------------------------------------------------------------
Prompter: BlackBerry World - Built for BlackBerry™
Prompter4Q: BlackBerry World - Built for BlackBerry™
Please use plain text.