tags:

views:

160

answers:

1

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.

A: 

Hey,

try use string() instead of text(), it should work.

Tiago Ferreira