[Qt-interest] Problem with URI in QXmlQuery

Jan Zegan jan at janzegan.com
Mon Apr 6 17:32:44 CEST 2009


Hello,
I posted this on two boards before, but got no responses and still
haven't figured it out myself.
I am executing an XQuery on data I get from Yahoo's financial site for
a single value, a change in currency rate since last trade. This which
works under Linux Qt 4.4.3 and doesn't under Qt 4.5.

here's the code:

QString query = "http://query.yahooapis.com/v1/public/yql?q=";
query += "select * from html where url=\"http://finance.yahoo.com/q?s=" +
tempQuote->getCode().toLower().replace(6, 1, "%3D") +   // this is
supposed to be something

                // like plnjpy=x, which becomes plnjpy%3Dx
"\" and (xpath='//span[@id=\"yfs_c10_" +
tempQuote->getCode().toLower() +                                   //
this stays plnjpy=x
"\"]/strong')&format=xml";

QString xq = "doc('%1')//query/results/strong[1]";

QXmlQuery queryxml;

queryxml.setQuery(xq.arg(query));

and the error i'm getting under Qt 4.5:
Error FODC0005 in file:///usr/bin/plasmoidviewer, at line 1, column 1:
http://query.yahooapis.com/v1/public/yql?q=select * from html where
url="http://finance.yahoo.com/q?s=plnjpy%3dx" and
(xpath='//span[@id="yfs_c10_plnjpy=x"]/strong')&format=xml is not a
valid value of type xs:anyURI.

>From what I played around (with slightly simpler queries), the
problems is somewhere here: [@id="yfs_c10_plnjpy=x"], most likely with
the '[' and ']', however percent encoding them returns this:

Error FODC0002 in
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url=%22http://finance.yahoo.com/q?s=gbppln%253Dx%22%20and%20(xpath='//span%255B@id=%22yfs_c10_gbppln=x%22%255B/strong')&format=xml:
Error downloading http://query.yahooapis.com/v1/public/yql?q=select *
from html where url="http://finance.yahoo.com/q?s=gbppln%3Dx" and
(xpath='//span%5B at id="yfs_c10_gbppln=x"%5B/strong')&format=xml -
server replied: Bad Request

For now, I opted for another way. I'm still using XQuery, but
downloading an entire page. This works but is quite slow as the query
may be executed several times. I would greatly appreciate any input.
Thanks!

-- 
Jan Zegan



More information about the Qt-interest-old mailing list