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
tushar886
Posts: 75
Registered: ‎08-15-2013
My Device: blackberry curve 9630
Accepted Solution

Creating XML file using blackberry cascades

Hi All,

 

I am using blackberry cascades to create a xml file which will consist of data QMessage.

 

The code which i am trying is as below:-

 

	foreach (const Message &message, inboxMessages) {
	
	// Creating QVariant Map for each Message object
	
	QVariantMap messageMap;
	messageMap["address"] = QVariant();
	messageMap["date"]
	messageMap["subject"] = QVariant(message.subject());
 	messageMap["body"] = ...........
	
	/ Adding this object to Qvariant List
	QVariantList messageList= QVariantList() << QVariant(messageMap);
	
	}  // end of for each loop

QVariantMap topLevelMessageMap;
topLevelMessageMap[".root"] = QVariant("messages");
topLevelMessageMap["message"] = QVariant(messageList);
QVariant myData = QVariant(topLevelMessageMap);
   
// Retrieve the working directory, and create a temporary .xml file in that
// location
QDir home = QDir::home();
QTemporaryFile file(home.absoluteFilePath("myXMLFile.xml"));
   
// Open the file that was created
if (file.open()) {
    // Create an XmlDataAccess object and save the data to the file
    XmlDataAccess xda;
    xda.save(myData, &file);

 IN the above code i have to create xml tags mannualy by using QVariant class.

 

However is there any way where xml schema can be used from xslt/xsd and it can be parsed to generate xml with data to be filled from Message class as per business logic.

 

Please suggest 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Creating XML file using blackberry cascades

what would that gain you? in my opinion that is not a valid usecase for xslas you have to fill in all values manually anyhow.
you can use xsl with qxmlquery, xmldataaccess does not have support for it.
----------------------------------------------------------
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