Getting data via XQuery then sorting and using it
-
Hello there,
I would like my program to gather results via an XQuery file and use the results as parameters for a function.
I am using a slightly modified version of the XQuery example to sift through the XML results. As you can see, the switch() function will contain the code to be executed when the condition is met. In this case (pun not intended) I would like it to store the value of the result. That value will later be used as a parameter for another function. So how can I store the values of the results and access them at the end of this function? Heres my code so far:@void sideBar::initializeSideBar()
{
QFile xqueryFile("/Users/nick/Desktop/files for NovaBrowser/sidebarQuery.xq");
xqueryFile.open(QIODevice::ReadWrite);QXmlQuery query; query.setQuery(&xqueryFile, QUrl::fromLocalFile(xqueryFile.fileName())); QXmlResultItems result; query.evaluateTo(&result); QXmlItem item(result.next()); while (!item.isNull()) { if (item.isAtomicValue()) { QVariant v = item.toAtomicValue(); switch (v.type()) { case QVariant::Int: //code? break; case QVariant::String: //code? break; default: // error break; } } else if (item.isNode()) { QXmlNodeModelIndex i = item.toNodeModelIndex(); //code? } item = result.next(); }
}
@thanks!