Qt XQuery into a QStringList

Posted by Stewart on Stack Overflow See other posts from Stack Overflow or by Stewart
Published on 2010-03-27T23:19:38Z Indexed on 2010/03/27 23:23 UTC
Read the original article Hit count: 183

Filed under:
|

Hi,

I'm trying to use QtXmlQuery to extract some data from XML. I'd like to put this into a QStringList. I try the following:

QByteArray in = "this is where my xml lives";
QBuffer received;
received.setData(in);
received.open(QIODevice::ReadOnly);

QXmlQuery query;
query.bindVariable("data", &received);
query.setQuery(NAMESPACE //contains definition of the t namespace
               "doc($data)//t:service/t:serviceID/text()");

QBuffer outb;
outb.open(QIODevice::ReadWrite);
QXmlSerializer s(query, &outb);
query.evaluateTo(&s);

qDebug() << "buffer" << outb.data(); //This works perfectly!

QStringList * queryResult = new QStringList();
query.evaluateTo(queryResult);

qDebug() << "string list" << *queryResult; //This gives me no output!

As you can see, everything works fine when I send the output into a QBuffer via a QXmlSerializer... but I get nothing when I try to use a QStringList.

© Stack Overflow or respective owner

Related posts about qt

Related posts about xquery