[PyQt] QXmlQuery (Xpath...)
celsowm
celsowm at gmail.com
Mon Nov 3 14:38:13 GMT 2008
I tried a sample for this: http://doc.trolltech.com/qq/qq25-webrobot.html
and code in python:
from PyQt4.QtCore import *
from PyQt4.QtXmlPatterns import *
query = QXmlQuery();
queryFile = QFile ("query.xq");
queryFile.open(QIODevice.ReadOnly);
queryString = QString();
queryString = QTextStream(queryFile).readAll();
url = QUrl("http://doc.trolltech.com/qq/");
item = QXmlItem(QVariant(url.toString()));
query.bindVariable("inputDocument",item)
query.setQuery(queryString, url);
outArray = QByteArray();
mybuffer = QBuffer (outArray);
mybuffer.open(QIODevice.ReadWrite);
formatter = QXmlFormatter (query, mybuffer);
query.evaluateTo(formatter)
mybuffer.close();
print query.isValid();
print QString.fromUtf8(outArray.data())
and errors in windows:
AppName: pythonw.exe AppVer: 0.0.0.0 ModName: qtcore4.dll
ModVer: 4.4.2.0 Offset: 000ddaf0
David Boddie wrote:
>
> On Tue, 28 Oct 2008 05:56:06 -0700 (PDT), celsowm wrote:
>
>> celsowm wrote:
>> > I tried a simple xptah sample, like this:
>> >
>> > from PyQt4 import QtXmlPatterns, QtCore
>> >
>> > query.setQuery("doc('index.htm')/html/body/p[1]");
>> > x = QtCore.QStringList;
>> > myFile = QtCore.QFile("index.htm")
>> > serializer = QtXmlPatterns.QXmlSerializer(query,myFile);
>> > query.evaluateTo(x); #dll error if use serealizer...
>
> Can you post the output, the versions of Qt and PyQt, and details of the
> platform you are using, please? If you really are getting a crash when
> you call this method, there's something seriously wrong somewhere.
>
> David
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>
--
View this message in context: http://www.nabble.com/QXmlQuery-%28Xpath...%29-tp20132548p20303914.html
Sent from the PyQt mailing list archive at Nabble.com.
More information about the PyQt
mailing list