[Qt-interest] Problems with XML and XQuery

Esdras Beleza listas at esdrasbeleza.com
Sat Jul 17 20:03:04 CEST 2010


doc($data) was wrong, since $data is not a filepath. I changed my query to

query.setQuery("$data/lfm/artist/name");

and now I obtaining this error:

Error XPTY0019 in file:///home/esdras/dev/player/Player, at line 1, column
1: Required type is node(), but xs:string was found.




Esdras

--
http://www.esdrasbeleza.com


On 17 July 2010 14:41, Jason H <scorp1us at yahoo.com> wrote:

> lfm/artist/name
>
> But you're getting a namespace error. hrm.
>
>
>
>
> ------------------------------
> *From:* Esdras Beleza <listas at esdrasbeleza.com>
> *To:* qt-interest at trolltech.com
> *Sent:* Sat, July 17, 2010 1:31:37 PM
> *Subject:* [Qt-interest] Problems with XML and XQuery
>
> Hi folks,
>
> I'm trying to parse a XML tree in the format of a QString. It's the
> response of a query to Last.fm web service described in
> http://www.lastfm.com.br/api/show?service=267 .
>
> The reply is in the variable replyString.
>
> My code snippet is:
>
> ---- 8< cut here ----
>     QXmlQuery query;
>     query.bindVariable("data", QXmlItem(replyString));
>     query.setQuery("doc($data)//artist/name");
>
>     QBuffer outb;
>     outb.open(QIODevice::ReadWrite);
>     QXmlSerializer s(query, &outb);
>     query.evaluateTo(&s);
>     qDebug() << "buffer" << outb.data();
>
>     QStringList *result = new QStringList();
>     query.evaluateTo(result);
>
>     qDebug("num: " + QString::number(result->count()).toUtf8());
> ---- 8< cut here ----
>
> I don't know if my XQuery code is right, but I'm getting this error:
>
> Error FODC0005 in file:///home/esdras/dev/player/Player, at line 1, column
> 1: <?xml version="1.0" encoding="utf-8"?>
>
> <lfm status="ok">
>
> <artist>
>
> (...) Long XML code (...)
>
> </artist></lfm>
>
> is not a valid value of type xs:anyURI.
>
>
> Please, does anyone know what I'm doing wrong? I can't find any
> documentation about parsing XML strings using Qt.
>
>
> Regards,
>
>
> Esdras
>
> --
> http://www.esdrasbeleza.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100717/100acb0a/attachment.html 


More information about the Qt-interest-old mailing list